Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

Commit

Permalink
Switched to using Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
assaf committed Jan 2, 2012
1 parent 2a719ae commit 2e56750
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 236 deletions.
234 changes: 0 additions & 234 deletions Cakefile

This file was deleted.

76 changes: 76 additions & 0 deletions Makefile
@@ -0,0 +1,76 @@
test :
vows --spec spec/*_spec.coffee


# Documentation consists of Markdown files converted to HTML, CSS/images copied over, annotated source code and PDF.
doc : html html/source html/zombie.pdf

html/index.html : README.md doc/layout/main.html
mkdir -p html
coffee doc/render.coffee $< $@

html/changelog.html : CHANGELOG.md doc/layout/main.html
mkdir -p html
coffee doc/render.coffee $< $@

html/%.html : doc/%.md doc/layout/main.html
mkdir -p html
coffee doc/render.coffee $< $@

html : $(foreach file,$(wildcard doc/*.md),html/$(notdir $(basename $(file))).html) html/index.html html/changelog.html
mkdir -p html
cp -fr doc/css doc/images html/

html/source : lib/**/*.coffee
@echo "Documenting source files ..."
docco lib/**/*.coffee
mkdir -p html
mv docs html/source

html/zombie.pdf : html/*.html
@echo "Generating PDF documentation ..."
wkhtmltopdf \
--disable-javascript --outline --print-media-type --title Zombie.js --header-html doc/layout/header.html --allow doc/images \
--margin-left 30 --margin-right 30 --margin-top 30 --margin-bottom 30 --header-spacing 5 \
cover doc/layout/cover.html toc --disable-dotted-lines \
html/index.html html/api.html html/selectors.html html/troubleshoot.html \
html/zombie.pdf


# Man pages.
man7 : $(foreach file,$(wildcard doc/*.md),man7/zombie-$(notdir $(basename $(file))).7) man7/zombie.7 man7/zombie-changelog.7
mkdir -p man7

man7/zombie.7 : README.md
mkdir -p man7
ronn --roff $< > $@

man7/zombie-changelog.7 : README.md
mkdir -p man7
ronn --roff $< > $@

man7/zombie-%.7 : doc/%.md
mkdir -p man7
ronn --roff $< > $@


# Clean up temporary directories
clean :
rm -rf html man7


# Get version number from package.json, need this for tagging.
version = $(shell node -e "console.log(JSON.parse(require('fs').readFileSync('package.json')).version)")

# Publish site only.
publish-docs : html html/source html/zombie.pdf
@echo "Uploading documentation ..."
rsync -chr --del --stats html/ labnotes.org:/var/www/zombie/

# npm publish, public-docs and tag
publish : test man7 publish-docs
git push
npm publish
git tag v$(version)
git push --tags origin master

2 changes: 1 addition & 1 deletion doc/guts.md
Expand Up @@ -22,7 +22,7 @@ can "install" your working directory using `npm link`.

To generate the documentation:

$ cake doc:pages
$ make doc
$ open html/index.html


Expand Down
2 changes: 1 addition & 1 deletion doc/layout/main.html
Expand Up @@ -13,7 +13,7 @@
<div id="sidebar">
<ul class="navigation">
<li><a href="/">Getting Started</a></li>
<li><a href="api.html">The API</a></li>
<li><a href="API.html">The API</a></li>
<li><a href="selectors.html">CSS Selectors</a></li>
<li><a href="troubleshoot.html">Troubleshooting</a></li>
<li><a href="guts.html">The Guts</a></li>
Expand Down
30 changes: 30 additions & 0 deletions doc/render.coffee
@@ -0,0 +1,30 @@
File = require("fs")
{ exec} = require("child_process")
HLJS = require("highlight/lib/vendor/highlight.js/highlight").hljs


# HLJS can't guess the language (JavaScript) consistently, so we're going to help by limiting its choice of languages to
# JavaScript and XML (good pick for one of the dumps).
require("highlight/lib/vendor/highlight.js/languages/xml")(HLJS)
require("highlight/lib/vendor/highlight.js/languages/javascript")(HLJS)

# Syntax highlighting
highlight = (html)->
unescape = (html)->
return html.replace(/&quot;/g, "\"").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">")
return html.replace(/<code>([\s\S]*?)<\/code>/gm, (_, source)-> "<code>#{HLJS.highlightText(unescape(source).replace(/\uffff/g,"\n"))}</code>")

# Markdown to HTML.
exec "ronn --html #{process.argv[2]}", (error, stdout, stderr)->
throw error if error
File.readFile "doc/layout/main.html", "utf8", (error, layout)->
throw error if error

[name, title] = stdout.match(/<h1>(.*)<\/h1>/)[1].split(" -- ")
name = name.replace(/\(\d\)/, "")
body = stdout.replace(/<h1>.*<\/h1>/, "")
html = layout.replace("{{body}}", body).replace(/{{title}}/g, title)
html = highlight(html)
File.writeFile process.argv[3], html, "utf8", (error)->
throw error if error
process.exit(0)

0 comments on commit 2e56750

Please sign in to comment.