From: Ralf Jung Date: Wed, 10 Jun 2015 06:50:03 +0000 (+0200) Subject: *sigh* go back to pycco... for now... X-Git-Url: https://git.ralfj.de/rust-101.git/commitdiff_plain/41c94f98f6cf8b5a05a8c3eb8d13bb73fc4fda3f?ds=sidebyside *sigh* go back to pycco... for now... --- diff --git a/.gitignore b/.gitignore index aabea6f..4903df5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ target/ -docs/ sync-docs rawsrc/ diff --git a/Makefile b/Makefile index dc3ffb0..706b1db 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ all: docs rawsrc .PHONY: docs rawsrc docs: - @docco $(FILES) # -l linear + @./pycco-rs $(FILES) rawsrc: @mkdir -p rawsrc diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..fe099b8 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,3 @@ +fonts/ +*.html +pycco.css diff --git a/docs/pycco_custom.css b/docs/pycco_custom.css new file mode 100644 index 0000000..bee0e24 --- /dev/null +++ b/docs/pycco_custom.css @@ -0,0 +1,31 @@ +/*--------------------- Typography ----------------------------*/ + +@font-face { + font-family: 'aller-light'; + src: url('fonts/aller-light.eot'); + src: url('fonts/aller-light.eot?#iefix') format('embedded-opentype'), + url('fonts/aller-light.woff') format('woff'), + url('fonts/aller-light.ttf') format('truetype'); + font-weight: normal; + font-style: normal; +} + +/*--------------------- Layout ----------------------------*/ +body { + font-family: 'aller-light', sans-serif; +} + +h1, h2, h3, h4, h5, h6 { + line-height: 1em; +} + +/*---------------------- Syntax Highlighting -----------------------------*/ +body .k { font-weight: bold } /* Keyword */ +body .kd { font-weight: normal } /* Keyword.Declaration */ +body .n { color: #19469D } /* Name */ + +body .mf { color: #40A070 } /* Literal.Number.Float */ +body .mh { color: #40A070 } /* Literal.Number.Hex */ +body .mi { color: #40A070 } /* Literal.Number.Integer */ +body .mo { color: #40A070 } /* Literal.Number.Oct */ +body .il { color: #40A070 } /* Literal.Number.Integer.Long */ diff --git a/pycco-rs b/pycco-rs new file mode 100755 index 0000000..bfb731c --- /dev/null +++ b/pycco-rs @@ -0,0 +1,27 @@ +#!/usr/bin/python +# A little wrapper around pycco, to add Rust support. +import pycco, pycco_resources +from pygments import lexers, formatters +import re + +# now, monkey-patch pycco for Rust support +pycco.main.languages[".rs"] = { "name": "rust", "symbol": "//"} +for ext, l in pycco.main.languages.items(): + # Does the line begin with a comment? + l["comment_matcher"] = re.compile(r"^\s*" + l["symbol"] + "\s?") + # The dividing token we feed into Pygments, to delimit the boundaries between + # sections. + l["divider_text"] = "\n" + l["symbol"] + "DIVIDER\n" + # The mirror of `divider_text` that we expect Pygments to return. We can split + # on this to recover the original sections. + l["divider_html"] = re.compile(r'\n*' + l["symbol"] + 'DIVIDER\n*') + # Get the Pygments Lexer for this language. + l["lexer"] = lexers.get_lexer_by_name(l["name"]) +# and monkey-patch for a custom CSS file +html_src = pycco_resources.html +marker = '' +custom_css = '' +patched_html = html_src.replace(marker, marker+custom_css, 1) +pycco.main.pycco_template = pycco.main.template(patched_html) + +pycco.main.main()