forked from mirrors/nixpkgs
Merge pull request #37901 from grahamc/doc/syntax-highlight
nixpkgs docs: syntax highlight
This commit is contained in:
commit
ab33c0afde
1
doc/.gitignore
vendored
1
doc/.gitignore
vendored
|
@ -3,3 +3,4 @@
|
|||
.version
|
||||
out
|
||||
manual-full.xml
|
||||
highlightjs
|
||||
|
|
24
doc/Makefile
24
doc/Makefile
|
@ -6,16 +6,17 @@ all: validate out/html/index.html out/epub/manual.epub
|
|||
.PHONY: debug
|
||||
debug:
|
||||
nix-shell --run "xmloscopy --docbook5 ./manual.xml ./manual-full.xml"
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f ${MD_TARGETS} .version manual-full.xml
|
||||
rm -rf ./out/
|
||||
rm -rf ./out/ ./highlightjs
|
||||
|
||||
.PHONY: validate
|
||||
validate: manual-full.xml
|
||||
jing "$$RNG" manual-full.xml
|
||||
|
||||
out/html/index.html: manual-full.xml style.css
|
||||
out/html/index.html: manual-full.xml style.css highlightjs
|
||||
mkdir -p out/html
|
||||
xsltproc ${xsltFlags} \
|
||||
--nonet --xinclude \
|
||||
|
@ -23,12 +24,22 @@ out/html/index.html: manual-full.xml style.css
|
|||
"$$XSL/docbook/xhtml/docbook.xsl" \
|
||||
./manual-full.xml
|
||||
|
||||
mkdir -p out/html/highlightjs/
|
||||
echo "document.onreadystatechange = function () { \
|
||||
var listings = document.querySelectorAll('.programlisting, .screen'); \
|
||||
for (i = 0; i < listings.length; ++i) { \
|
||||
hljs.highlightBlock(listings[i]); \
|
||||
} \
|
||||
} " > out/html/highlightjs/loader.js
|
||||
|
||||
cp -r highlightjs out/html/
|
||||
|
||||
cp ./overrides.css out/html/
|
||||
cp ./style.css out/html/style.css
|
||||
|
||||
mkdir -p out/html/images/callouts
|
||||
cp "$$XSL/docbook/images/callouts/"*.svg out/html/images/callouts/
|
||||
chmod u+w -R out/html/images/
|
||||
chmod u+w -R out/html/
|
||||
|
||||
out/epub/manual.epub: manual-full.xml
|
||||
mkdir -p out/epub/scratch
|
||||
|
@ -47,6 +58,13 @@ out/epub/manual.epub: manual-full.xml
|
|||
cd "out/epub/scratch/" && zip -Xr9D "../manual.epub" *
|
||||
rm -rf "out/epub/scratch/"
|
||||
|
||||
highlightjs:
|
||||
mkdir -p highlightjs
|
||||
cp -r "$$HIGHLIGHTJS/highlight.pack.js" highlightjs/
|
||||
cp -r "$$HIGHLIGHTJS/LICENSE" highlightjs/
|
||||
cp -r "$$HIGHLIGHTJS/mono-blue.css" highlightjs/
|
||||
|
||||
|
||||
manual-full.xml: ${MD_TARGETS} .version *.xml
|
||||
xmllint --nonet --xinclude --noxincludenode manual.xml --output manual-full.xml
|
||||
|
||||
|
|
|
@ -11,12 +11,18 @@ pkgs.stdenv.mkDerivation {
|
|||
|
||||
src = ./.;
|
||||
|
||||
# Hacking on these variables? Make sure to close and open
|
||||
# nix-shell between each test, maybe even:
|
||||
# $ nix-shell --run "make clean all"
|
||||
# otherwise they won't reapply :)
|
||||
HIGHLIGHTJS = pkgs.documentation-highlighter;
|
||||
XSL = "${pkgs.docbook5_xsl}/xml/xsl";
|
||||
RNG = "${pkgs.docbook5}/xml/rng/docbook/docbook.rng";
|
||||
xsltFlags = lib.concatStringsSep " " [
|
||||
"--param section.autolabel 1"
|
||||
"--param section.label.includes.component.label 1"
|
||||
"--stringparam html.stylesheet 'style.css overrides.css'"
|
||||
"--stringparam html.stylesheet 'style.css overrides.css highlightjs/mono-blue.css'"
|
||||
"--stringparam html.script './highlightjs/highlight.pack.js ./highlightjs/loader.js'"
|
||||
"--param xref.with.number.and.title 1"
|
||||
"--param toc.section.depth 3"
|
||||
"--stringparam admon.style ''"
|
||||
|
|
|
@ -104,7 +104,7 @@ pre.screen, pre.programlisting
|
|||
padding: 3px 3px;
|
||||
margin-left: 1.5em;
|
||||
margin-right: 1.5em;
|
||||
color: #600000;
|
||||
|
||||
background: #f4f4f8;
|
||||
font-family: monospace;
|
||||
border-radius: 0.4em;
|
||||
|
|
Loading…
Reference in a new issue