Commit Graph

94 Commits

Author SHA1 Message Date
Mike West
5271a2ba31 Dropping some debug 'puts' statements. 2010-11-25 17:09:48 +01:00
Mike West
12b26fe704 Relative paths in the source jumplist
Adding a dependency on `Pathname`, which provides the excellent
`relative_path_from` method.  That happens to be exactly what's needed
to fix the pathnames for the source jumplist issue that [Topfunky][]
reported.

Closes GH-26.

[Topfunky]: https://github.com/topfunky
2010-11-25 16:41:30 +01:00
Mike West
9d49139090 Fixing block comment highlighting for block-only languages
Languages without single-line comments (CSS) explode when running
through `highlight`, as the `DIVIDER` mechanism doesn't deal well with
`nil` comment characters.  I've reworked the mechanism such that it
uses multi-line comments when single-line comments aren't available.
2010-11-25 16:12:28 +01:00
Mike West
1fa99adbda Every project needs a changelog. 2010-11-23 19:55:36 +01:00
Mike West
cffe49a813 Fixing bugs that popped up as soon as I ran rake 2010-11-22 15:00:36 +01:00
Mike West
1262d50857 Merge branch 'blockcomments' 2010-11-22 14:42:56 +01:00
Mike West
b11543d382 Normalizing leading space in comments
That is:

    def function:
        """
            This is a comment
            with _lots_ of leading
            space!  OMG!
        """
        pass

Will parse into:

    [
        [
            [   "This is a comment",
                "with _lots_ of leading",
                "space!  OMG!"
            ],
            ...
        ]
    ]
2010-11-22 14:42:21 +01:00
Mike West
d0211ecc99 Python block comments (no middle character), and CSS syntax 2010-11-22 13:38:03 +01:00
Mike West
77dff765b6 Fixing tests for block comments. 2010-11-22 08:41:54 +01:00
Mike West
f177a9d7e2 Block comment parsing: basics.
Block comments are parsed out, but the commentchar removal isn't working
yet.  I'll refactor that code out of it's current home, and move it into
`parse`, as I need to know what _kind_ of comment it is that I'm
stripping.  Carrying that metadata around doesn't make any sense, so
I'll just convert the comment on the fly into a set of non-comment
strings.
2010-11-22 08:25:40 +01:00
Mike West
d067210faa Refactoring comment_char internals: prepping for block comments 2010-11-21 16:53:22 +01:00
Mike West
7609e1a624 Adding Ruby block comment syntax.
Working towards GH-22.
2010-11-21 16:36:20 +01:00
Vasily Poloynyov
ba93d23634 Really fixing extensionless file support
Pieced together a fix using Regex and `File.extname` from http://github.com/vast/rocco

Closes GH-24.
2010-11-21 16:18:28 +01:00
Mike West
515966dcc9 Locking the CSS file down to Docco's v0.3.0
I'm a bit loath to change the rendering entirely without talking to
Ryan, but I'd really prefer to replicate Docco's CSS file generation
rather than hotlinking out to the GitHub-hosted version.  Offline
support would require it, if for no other reason...

Closes GH-23.  Thanks to [Myles Byrne](http://www.myles.id.au/)
2010-11-21 15:41:22 +01:00
Mike West
6aa2217706 Refactoring tests out into separate files. 2010-10-24 11:08:04 +02:00
Mike West
e506c5172a Skipping Python/Ruby 1.9 source encoding
In the same way that it makes sense to skip the shebang (#!) line in
scripts, it makes sense to skip the encoding definition in Python files
(described by [PEP 263][p]) and Ruby 1.9 files (similar enough syntax
that it's not worth worrying about.

[p]: http://www.python.org/dev/peps/pep-0263/
2010-10-21 20:10:30 +02:00
Mike West
a4d0e41413 Cleanup inline documentation, small code reorg. 2010-10-21 20:04:17 +02:00
Mike West
b87f4a63e3 Merge branch 'language' 2010-10-20 17:08:46 +02:00
Mike West
185da24fc3 Cleaning up indent spacing in test file. 2010-10-20 17:07:32 +02:00
Mike West
020e8050bc Autopopulate comment_chars for known languages
Adding comment characters for bash, c, c++, coffee script, java, javascript, lua, python, ruby, and scheme.  Paving the way for block-comment parsing later on...

Closes issue #20.
2010-10-20 17:07:14 +02:00
Mike West
0b392c1094 Attempt to autodetect file language
`pygmentize` 1.0+ has an `-N` option that attempts to match a file (via
the extension) to a language lexer.  If `pygmentize` is installed, we'll
run it with this option to get a language.

If no language is detected, `pygmentize -N` returns `text`.  In that case,
we'll first look for a user-provided language to use as a fallback.  If no
language was provided, highlight using `ruby` as a reasonable default.

Closes issue #19.
2010-10-20 15:11:07 +02:00
Mike West
a43f0fc584 Typo: Closes issue #11
Thanks to Paul Chavard ( http://github.com/tchak ) for
the report and fix.
2010-10-20 14:27:03 +02:00
Mike West
1b211bcc08 Specify encoding for Pygments
This closes issue #10, in theory, but I'm not completely happy with the
behavior.  The output for both UTF-8 and ISO-8859-1 sources is arguably
correct, but I think it'd be better to do some autodetecting of the file
encoding, and explicitly convert everything to UTF-8 on input.  One
option is the [`chardet` gem][gem], but I'm loath to add another
dependency to Rocco...

[gem]: http://rubygems.org/gems/chardet/versions/0.9.0
2010-10-19 13:32:03 +02:00
Mike West
38683a8cc2 Cleaning up tests after bugfix merges:
As a result of fixing issue #15, a few tests broken.  This commit brings
the tests up to date with the latest behavior.
2010-10-19 13:08:13 +02:00
Ryan Tomayko
94b3fd4e51 task :default => :test 2010-10-19 03:39:13 -07:00
Ryan Tomayko
f144e7e3b2 Merge remote branch 'mikewest/test' 2010-10-19 03:35:46 -07:00
Ryan Tomayko
236fb2731c Merge remote branch 'mikewest/template'
Conflicts:
	lib/rocco.rb
2010-10-19 03:35:33 -07:00
Ryan Tomayko
6266408828 Merge remote branch 'mikewest/master' 2010-10-19 03:35:13 -07:00
Mike West
6cf8de0a02 Adding a basic test suite. 2010-10-17 20:46:28 +02:00
Mike West
bb9b167b13 Variables for use in Mustache templates.
Added:

*   `docs?`:    True if `docs` contains text of any sort, False if
                it's empty.

*   `code?`:    True if `code` contains text of any sort, False if
                it's empty.

*   `empty?`:   True if both `code` and `docs` are empty.  False
                otherwise.

*   `header?`:  True if `docs` contains _only_ a HTML header.  False
                otherwise.
2010-10-17 13:16:45 +02:00
Mike West
bb8fcb9ef0 Adding CLI argument template
In v0.5, the Mustache template is hardcoded as
`./lib/rocco/layout.mustache`.  This makes it quite difficult to
style generated content as one must edit the layout file inside the
gem itself to make changes.

I propose leaving that file as a sensible default, but allowing the user
to specify an absolute or relative (to the current working directory)
path to a mustach template of her choosing.  That's implemented in this
commit.
2010-10-17 12:25:35 +02:00
Mike West
b9b69d98fb Fixing (among other things) alternate header syntax
The following works in Docco, but not in Rocco:

    Level 1 Heading
    ===============

    Level 2 Heading
    ---------------

Happily, the fix is trivial.  In Docco, the regex for comments is:

    # Does the line begin with a comment?
    l.comment_matcher = new RegExp('^\\s*' + l.symbol + '\\s?')

Changing Rocco's comment pattern to:

    @comment_pattern = Regexp.new("^\\s*#{@options[:comment_chars]}\s?")

Solves the problem for me.
2010-10-14 18:57:35 +02:00
Mike West
198be61e7c Fixing code highlighting in bash mode
Rocco splits against `<span class="c.">`, which works fine for Ruby
where the `span` has a class of `c1`, but fails for Bash (and probably
other languages), where the `span` has a class of `c`.  The fix is
trivial.
2010-10-14 18:31:20 +02:00
Mike West
939e7f0e8a Integrate pilcrow change from Docco
Rocco uses the Docco CSS directly, so when they make an update to the
HTML/CSS, Rocco needs to play along.  In this case, Docco changed from
`#` to `¶`, and changed classnames as well (in
[f8a88d66b381a1c04358][]).

This commit migrates that change to Rocco.

[f8a88d66b381a1c04358]:
f8a88d66b3
2010-10-14 18:21:31 +02:00
Ryan Tomayko
e57b208570 0.5 release 2010-09-10 10:32:31 -07:00
Colin Shea
6aa7bd6a33 Really support extension-less files (and still support -o) 2010-04-03 08:14:44 +08:00
Ryan Tomayko
889fcb286b Merge Ruby 1.9 fixes from evaryont/master 2010-04-02 16:02:27 -07:00
Ryan Tomayko
eed5d48981 avoid which(1) 2010-04-02 15:59:52 -07:00
Ryan Tomayko
957e5cf197 Merge a bunch of stuff from burke/master 2010-04-02 15:53:39 -07:00
Ryan Tomayko
feb22ad147 create output dirs before writing files 2010-04-02 15:46:12 -07:00
Marko Mikulicic
367437fec5 honour -o 2010-04-02 15:39:16 -07:00
Burke Libbey
c1a4dd756a prefer .blank? to == '' 2010-03-30 15:26:31 -05:00
Burke Libbey
3dc4f87c12 code DIVIDER is now language-agnostic. 2010-03-30 15:18:17 -05:00
Burke Libbey
6595d5f885 bin/rocco works for extensionless files now (again?) too. README -> README.html. 2010-03-30 15:01:01 -05:00
Burke Libbey
8c948bbb95 fixed -o option 2010-03-30 14:55:26 -05:00
Burke Libbey
55700ff584 change a class in a regex to deal with the way pygments outputs C code. 2010-03-30 14:38:01 -05:00
Burke Libbey
2f54f4c424 send @options['language'] to pygments.appspot.com, not just 'ruby'. 2010-03-30 14:08:12 -05:00
Burke Libbey
17eeb9e75f fixed syntax error, re-added warning for webservice 2010-03-30 14:07:30 -05:00
Burke Libbey
68b1529714 Removed warning about pygmentize not being installed. 2010-03-30 13:57:45 -05:00
Burke Libbey
fb4b5404ae just use the pygments.appspot.com if there's no pygmentize on the path, rather than as a command line flag 2010-03-30 13:46:24 -05:00