-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix example codes (2018-06) #6315
Conversation
src/http/common.cr
Outdated
@@ -246,7 +246,7 @@ module HTTP | |||
# timezone `GMT` (interpreted as `UTC`). | |||
# | |||
# ``` | |||
# HTTP.format_time(Time.new(2016, 2, 15)) # => "Sun, 14 Feb 2016 21:00:00 GMT" | |||
# HTTP.format_time(Time.new(2016, 2, 15)) # => "Mon, 15 Feb 2016 00:00:00 GMT" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output depends on local time zone configuration. Time.new
should better receive a specific time zone.
src/time.cr
Outdated
# time = Time.new(2016, 2, 15, 10, 20, 30, location: Time::Location.load("Europe/Berlin")) | ||
# time.to_s # => 2016-02-15 10:20:30 +01:00 Europe/Berlin | ||
# The time-of-day can be omitted and defaults to midnight (start of day): | ||
# time # => 2016-02-15 10:20:30 +01:00 Europe/Berlin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add .to_s
and wrap result in quotes like in the other examples.
src/time.cr
Outdated
@@ -907,7 +907,7 @@ struct Time | |||
# Format this time using the format specified by [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt). | |||
# | |||
# ``` | |||
# Time.new(2016, 2, 15).to_rfc2822 # => "Mon, 15 Feb 2016 00:00:00 -0400" | |||
# Time.new(2016, 2, 15).to_rfc2822 # => "Mon, 15 Feb 2016 00:00:00 +0000" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example should use a specific time zone.
src/time/format/custom/http_date.cr
Outdated
@@ -12,7 +12,7 @@ require "./rfc_2822" | |||
# Time::Format::HTTP_DATE.parse("Sunday, 14-Feb-16 21:00:00 GMT") # => 2016-02-14 21:00:00 UTC | |||
# Time::Format::HTTP_DATE.parse("Sun Feb 14 21:00:00 2016") # => 2016-02-14 21:00:00 UTC | |||
# | |||
# Time::Format::HTTP_DATE.format(Time.new(2016, 2, 15)) # => "Sun, 14 Feb 2016 21:00:00 GMT" | |||
# Time::Format::HTTP_DATE.format(Time.new(2016, 2, 15)) # => "Mon, 15 Feb 2016 00:00:00 GMT" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example should use a specific time zone.
src/time.cr
Outdated
@@ -873,7 +873,7 @@ struct Time | |||
# Format this time using the format specified by [RFC 3339](https://tools.ietf.org/html/rfc3339) ([ISO 8601](http://xml.coverpages.org/ISO-FDIS-8601.pdf) profile). | |||
# | |||
# ``` | |||
# Time.new(2016, 2, 15).to_rfc3339 # => "2016-02-15T00:00:00+00:00" | |||
# Time.new(2016, 2, 15).to_rfc3339 # => "2016-02-15T00:00:00Z" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example should use a specific time zone.
@straight-shoota thanks. I added timezone by using |
@maiha Nice! How long does it take to compile and run all examples? Do you generate a single big program, or is it one compilation per example? |
For example, this is a generated spec file from |
I forgot to run |
8 minutes is a lot of time, but I guess for smaller projects it will be a reasonable time. I wonder if we should embed this feature directly in the compiler. That way we'll have I think the CI already takes a lot of time, so 8 minutes more isn't thaaat bad :-P Thoughts? |
It's not needed to add on the CI, because this is only about comments at the end, not code. Having some incorrect docs doesn't prevent to have a working crystal compiler. |
Execution time can be reduced by caching. So I think it is not a big problem. As @j8r is worried, it is a problem that there is a not working code case. Actually, there are many image codes like the following.
It takes time manually to judge this. And Most of the time is spent here.😱 |
@j8r It's not strictly necessary, but really nice to have if the code examples are automatically validated. This doesn't even need to be integrated in the compiler. We could run the examples checker right now in CI. @maiha Sure, some examples need manual intervention, but that's what this is about. Having automatic checks in CI would prevent simple errors and encourage people to write working examples. Obviously, not every example can be written in a way that it is actually executable. But it should be quite easy to flag such examples as ignore. For example using a special syntax highlight declaration: |
@maiha this need a rebase and good to go 👍 |
cc182ce
to
6063be9
Compare
rebased. I hope this will be merged before another conflict occurs. 😃 |
Thanks @maiha |
Congrats 0.25.1! And fixed example codes.
0.25.1 [b782738]
PR
Best regards,