Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Conversation

@lambda
Copy link

@lambda lambda commented Jan 5, 2012

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 .gitignore to properly ignore the generated docs directory.

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.

lambda added 3 commits January 9, 2012 16:28
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.
@lambda
Copy link
Author

lambda commented Jan 9, 2012

Any chance that someone could review these and either pull them or let me know what I should do differently?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant