From ab1648bf0d13afc19bdf7e3d092a3f7ce15a4de1 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 30 Apr 2018 22:35:54 -0400 Subject: [PATCH] nixpkgs doc: add format Make target --- doc/Makefile | 7 +++- doc/default.nix | 3 +- doc/shell.nix | 1 + nixos/doc/xmlformat.conf | 72 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 nixos/doc/xmlformat.conf diff --git a/doc/Makefile b/doc/Makefile index 952ef4bfcbb9..8a4612e95f19 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,12 +1,17 @@ MD_TARGETS=$(addsuffix .xml, $(basename $(wildcard ./*.md ./**/*.md))) .PHONY: all -all: validate out/html/index.html out/epub/manual.epub +all: validate format out/html/index.html out/epub/manual.epub .PHONY: debug debug: nix-shell --run "xmloscopy --docbook5 ./manual.xml ./manual-full.xml" +.PHONY: format +format: + find . -iname '*.xml' -type f -print0 | xargs -0 -I{} -n1 \ + xmlformat --config-file "$$XMLFORMAT_CONFIG" -i {} + .PHONY: clean clean: rm -f ${MD_TARGETS} .version manual-full.xml diff --git a/doc/default.nix b/doc/default.nix index e5be364506ff..0d95d3f04573 100644 --- a/doc/default.nix +++ b/doc/default.nix @@ -7,7 +7,7 @@ in pkgs.stdenv.mkDerivation { name = "nixpkgs-manual"; - buildInputs = with pkgs; [ pandoc libxml2 libxslt zip jing ]; + buildInputs = with pkgs; [ pandoc libxml2 libxslt zip jing xmlformat ]; src = ./.; @@ -18,6 +18,7 @@ pkgs.stdenv.mkDerivation { HIGHLIGHTJS = pkgs.documentation-highlighter; XSL = "${pkgs.docbook5_xsl}/xml/xsl"; RNG = "${pkgs.docbook5}/xml/rng/docbook/docbook.rng"; + XMLFORMAT_CONFIG = ../nixos/doc/xmlformat.conf; xsltFlags = lib.concatStringsSep " " [ "--param section.autolabel 1" "--param section.label.includes.component.label 1" diff --git a/doc/shell.nix b/doc/shell.nix index 22590142ee1a..e8da2eaf16be 100644 --- a/doc/shell.nix +++ b/doc/shell.nix @@ -1,4 +1,5 @@ { pkgs ? import ../. {} }: (import ./default.nix).overrideAttrs (x: { buildInputs = x.buildInputs ++ [ pkgs.xmloscopy ]; + }) diff --git a/nixos/doc/xmlformat.conf b/nixos/doc/xmlformat.conf new file mode 100644 index 000000000000..50255857b24a --- /dev/null +++ b/nixos/doc/xmlformat.conf @@ -0,0 +1,72 @@ +# +# DocBook Configuration file for "xmlformat" +# see http://www.kitebird.com/software/xmlformat/ +# 10 Sept. 2004 +# + +# Only block elements +ackno address appendix article biblioentry bibliography bibliomixed \ +biblioset blockquote book bridgehead callout calloutlist caption caution \ +chapter chapterinfo classsynopsis cmdsynopsis colophon constraintdef \ +constructorsynopsis dedication destructorsynopsis entry epigraph equation example \ +figure formalpara funcsynopsis glossary glossdef glossdiv glossentry glosslist \ +glosssee glossseealso graphic graphicco highlights imageobjectco important \ +index indexdiv indexentry indexinfo info informalequation informalexample \ +informalfigure informaltable legalnotice literallayout lot lotentry mediaobject \ +mediaobjectco msgmain msgset note orderedlist para part preface primaryie \ +procedure qandadiv qandaentry qandaset refentry refentrytitle reference \ +refnamediv refsect1 refsect2 refsect3 refsection revhistory screenshot sect1 \ +sect2 sect3 sect4 sect5 section seglistitem set setindex sidebar simpara \ +simplesect step substeps synopfragment synopsis table term title \ +toc variablelist varlistentry warning itemizedlist listitem \ +footnote colspec partintro row simplelist subtitle tbody tgroup thead tip + format block + normalize no + + +#appendix bibliography chapter glossary preface reference +# element-break 3 + +sect1 section + element-break 2 + + +# +para abstract + format block + entry-break 1 + exit-break 1 + normalize yes + wrap-length 79 + +title + format block + normalize = yes + entry-break = 0 + exit-break = 0 + +# Inline elements +abbrev accel acronym action application citation citebiblioid citerefentry citetitle \ +classname co code command computeroutput constant country database date email emphasis \ +envar errorcode errorname errortext errortype exceptionname fax filename \ +firstname firstterm footnoteref foreignphrase funcdef funcparams function \ +glossterm group guibutton guiicon guilabel guimenu guimenuitem guisubmenu \ +hardware holder honorific indexterm inlineequation inlinegraphic inlinemediaobject \ +interface interfacename \ +keycap keycode keycombo keysym lineage link literal manvolnum markup medialabel \ +menuchoice methodname methodparam modifier mousebutton olink ooclass ooexception \ +oointerface option optional otheraddr othername package paramdef parameter personname \ +phrase pob postcode productname prompt property quote refpurpose replaceable \ +returnvalue revnumber sgmltag state street structfield structname subscript \ +superscript surname symbol systemitem token trademark type ulink userinput \ +uri varargs varname void wordasword xref year mathphrase member tag + format inline + +programlisting screen + format verbatim + entry-break = 0 + exit-break = 0 + + +#term +# format inline