Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jashkenas/docco
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Aug 23, 2011
2 parents 1481be5 + 9e58550 commit addef43
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
26 changes: 16 additions & 10 deletions lib/docco.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 14 additions & 5 deletions src/docco.coffee
Expand Up @@ -9,8 +9,8 @@
#
# docco src/*.coffee
#
# ...will generate linked HTML documentation for the named source files, saving
# it into a `docs` folder.
# ...will generate an HTML documentation page for each of the named source files,
# with a menu linking to the other pages, saving it into a `docs` folder.
#
# The [source for Docco](http://github.com/jashkenas/docco) is available on GitHub,
# and released under the MIT license.
Expand Down Expand Up @@ -103,20 +103,29 @@ highlight = (source, sections, callback) ->
language = get_language source
pygments = spawn 'pygmentize', ['-l', language.name, '-f', 'html', '-O', 'encoding=utf-8']
output = ''

pygments.stderr.addListener 'data', (error) ->
console.error error if error

pygments.stdin.addListener 'error', (error) ->
console.error "Could not use Pygments to highlight the source."
process.exit 1

pygments.stdout.addListener 'data', (result) ->
output += result if result

pygments.addListener 'exit', ->
output = output.replace(highlight_start, '').replace(highlight_end, '')
fragments = output.split language.divider_html
for section, i in sections
section.code_html = highlight_start + fragments[i] + highlight_end
section.docs_html = showdown.makeHtml section.docs_text
callback()
pygments.stdin.write((section.code_text for section in sections).join(language.divider_text))
pygments.stdin.end()


if pygments.stdin.writable
pygments.stdin.write((section.code_text for section in sections).join(language.divider_text))
pygments.stdin.end()

# Once all of the code is finished highlighting, we can generate the HTML file
# and write out the documentation. Pass the completed sections into the template
# found in `resources/docco.jst`
Expand Down

0 comments on commit addef43

Please sign in to comment.