This repository was archived by the owner on Nov 9, 2017. It is now read-only.
Two bugfixes: display output when there are no comments, allow non-UTF-8 encodings#72
Open
lambda wants to merge 3 commits intortomayko:masterfrom
Open
Two bugfixes: display output when there are no comments, allow non-UTF-8 encodings#72lambda wants to merge 3 commits intortomayko:masterfrom
lambda wants to merge 3 commits intortomayko:masterfrom
Conversation
Rocco should display the code even if there are no comments. When there are
no comments, it produces a single section with an empty docs string.
However, to pass it through Markdown, it joins the sections with a
delimiter, munges that, and split the result. Joining a list continaing the
empty string and splitting it again produces an empty list, not a list
containting the empty string:
> [""].join("delim").split("delim")
=> []
In Ruby 1.9, this causes us lose the associated code when when try to zip
these lists back together again:
> [].zip(["something"])
=> []
To fix this, just make sure `docs_html` contains at least a single empty
string if it winds up being empty.
Fixes: rtomayko#71 (fix rtomayko#71)
Ruby 1.9 is much more strict about encodings; instead of just reading bytes into the string and hoping you know how to interpret it, it actually keeps track of what encoding it expects the file and the string to be and transcodes between them. This means that we can no longer just read in the ISO-8859-1 as binary, and kind of hope that everything later on ignores it or knows how to cope. Instead, we need to explicitly choose to read the file as ISO-8859-1, and explicitly choose the encoding that we want the string to be in. We use UTF-8, because that's what Pygments and at least some of the Markdown libraries are expecting. Fixes: rtomayko#73 (fix rtomayko#73)
Commit 854f62c (The default gitignore provided by `bundler gem`) replaced .gitignore with a generated one, but that blew away the .gitignore line for /docs. Add it back in.
Author
|
Any chance that someone could review these and either pull them or let me know what I should do differently? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've pushed two bugfixes to my fork; one to make sure that we get output even when there are no comments in the file (issue 71) and one to allow explicit specification of input file encoding so we can properly handle non-UTF-8 input on Ruby 1.9 (issue 73). This pull request also updates
.gitignoreto properly ignore the generateddocsdirectory.I had submitted this pull request earlier with some other patches mixed in, but I've now cleaned it up and rebased it on the latest code.