* Fix hyperlink generation, but now in XSLT instead of sed.

svn path=/nixos/trunk/; revision=17660
This commit is contained in:
Eelco Dolstra 2009-10-05 23:47:50 +00:00
parent 6b3b22537e
commit 824e94cf0a
2 changed files with 20 additions and 22 deletions

View file

@ -11,30 +11,13 @@ let
options //
{ system = removeAttrs options.system ["path"]; };
optionsXML_ = builtins.toFile "options.xml" (builtins.unsafeDiscardStringContext
optionsXML = builtins.toFile "options.xml" (builtins.unsafeDiscardStringContext
(builtins.toXML (pkgs.lib.optionAttrSetToDocList "" options_)));
optionsXML = pkgs.runCommand "options2.xml" {} ''
sed '
\,<attr name="\(declarations\|definitions\)">, {
n # fetch the next line
: rewriteLinks
n # fetch the next line
\,</list>, b # leave if this is the end of the list
${if revision == "local" then "" else ''
# redirect nixos internals to the repository
s,<string value="[^"]*/modules/\([^"]*\)" />,<string value="!https://svn.nixos.org/viewvc/nix/nixos/trunk/modules/\1?revision=${revision}!!../nixos/modules/\1!" />, #"
t rewriteLinks # jump to rewriteLinks if done
''}
# redirect local file to their locations
s,<string value="\([^"]*\)" />,<string value="!file://\1\!!../nixos/modules/\1!" />, #"
b rewriteLinks # jump to rewriteLinks
}
' ${optionsXML_} > $out
'';
optionsDocBook = pkgs.runCommand "options-db.xml" {} ''
${pkgs.libxslt}/bin/xsltproc -o $out ${./options-to-docbook.xsl} ${optionsXML_}
${pkgs.libxslt}/bin/xsltproc \
--stringparam revision '${revision}' \
-o $out ${./options-to-docbook.xsl} ${optionsXML}
'';
manual = pkgs.stdenv.mkDerivation {

View file

@ -10,6 +10,8 @@
<xsl:output method='xml' encoding="UTF-8" />
<xsl:param name="revision" />
<xsl:template match="/expr/list">
@ -140,7 +142,20 @@
<xsl:template match="attr[@name = 'declarations' or @name = 'definitions']">
<simplelist>
<xsl:for-each select="list/string">
<member><filename xlink:href="http://example.org"><xsl:value-of select="@value" /></filename></member>
<member><filename>
<!-- Hyperlink the filename either to the NixOS Subversion
repository (if its a module and we have a revision number),
or to the local filesystem. -->
<xsl:choose>
<xsl:when test="$revision != 'local' and contains(@value, '/modules/')">
<xsl:attribute name="xlink:href">https://svn.nixos.org/viewvc/nix/nixos/trunk/modules/<xsl:value-of select="substring-after(@value, '/modules/')"/>?revision=<xsl:value-of select="$revision"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="xlink:href">file://<xsl:value-of select="@value"/></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="@value" />
</filename></member>
</xsl:for-each>
</simplelist>
</xsl:template>