* [gentoo-commits] proj/devmanual:master commit in: /, bin/
@ 2019-03-22 13:27 Brian Evans
0 siblings, 0 replies; 10+ messages in thread
From: Brian Evans @ 2019-03-22 13:27 UTC (permalink / raw
To: gentoo-commits
commit: d541c4c23305121c02ed18668b6019e86cfc2404
Author: Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 22 13:19:16 2019 +0000
Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Fri Mar 22 13:19:16 2019 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=d541c4c2
Create script for eclass-reference
This was previously held in infra but contains no identifying information
Bug: https://bugs.gentoo.org/536654
Signed-off-by: Brian Evans <grknight <AT> gentoo.org>
.gitignore | 1 +
bin/gen-eclass-html.sh | 135 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 136 insertions(+)
diff --git a/.gitignore b/.gitignore
index b364f07..720d4d6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
*.html
*.png
+eclass-reference/
diff --git a/bin/gen-eclass-html.sh b/bin/gen-eclass-html.sh
new file mode 100755
index 0000000..e87f60f
--- /dev/null
+++ b/bin/gen-eclass-html.sh
@@ -0,0 +1,135 @@
+#!/bin/bash
+
+# pre1) OOB: The host needs to emerge eclass-manpages on a daily basis.
+# This script should be run before the make operation is performed
+
+OUTPUTDIR="eclass-reference"
+
+IFS='' read -r -d '' FOOTER << 'EOF'
+</div>
+<footer><div class="container">
+<div class="row">
+<div class="col-xs-12 col-md-offset-2 col-md-7"></div>
+<div class="col-xs-12 col-md-3">
+<h3 class="footerhead">Questions or comments?</h3>
+ Please feel free to <a href="https://www.gentoo.org/inside-gentoo/contact/">contact us</a>.
+ </div>
+</div>
+<div class="row">
+<div class="col-xs-2 col-sm-3 col-md-2"><ul class="footerlinks three-icons">
+<li><a href="http://twitter.com/gentoo" title="@Gentoo on Twitter"><span class="fa fa-twitter fa-fw"></span></a></li>
+<li><a href="https://plus.google.com/+Gentoo" title="+Gentoo on Google+"><span class="fa fa-google-plus fa-fw"></span></a></li>
+<li><a href="https://www.facebook.com/gentoo.org" title="Gentoo on Facebook"><span class="fa fa-facebook fa-fw"></span></a></li>
+</ul></div>
+<div class="col-xs-10 col-sm-9 col-md-10">
+<strong>Copyright (C) 2001-2019 Gentoo Foundation, Inc.</strong><br><small>
+ Gentoo is a trademark of the Gentoo Foundation, Inc.
+ The text of this document is distributed under the
+ <a href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.
+ The <a href="https://www.gentoo.org/inside-gentoo/foundation/name-logo-guidelines.html">Gentoo Name and Logo Usage Guidelines</a> apply.
+ </small>
+</div>
+</div>
+</div></footer><script src="https://assets.gentoo.org/tyrian/jquery.min.js"></script><script src="https://assets.gentoo.org/tyrian/bootstrap.min.js"></script>
+</body>
+</html>
+EOF
+
+# We also need the ebuild man page
+for i in $(/usr/bin/qlist eclass-manpages) /usr/share/man/man5/ebuild.5.bz2; do
+ BASENAME="$(basename $i .5.bz2)"
+ DIRNAME="${OUTPUTDIR}/${BASENAME}"
+ TMP="${DIRNAME}/index.html.tmp"
+ FINAL="${DIRNAME}/index.html"
+ [[ -d ${DIRNAME} ]] || mkdir -p ${DIRNAME}
+ # rebuild the man page each time
+ cat << EOF > ${FINAL}
+<!DOCTYPE html><html lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Gentoo Development Guide: $BASENAME</title>
+ <link rel="stylesheet" href="../../devmanual.css" type="text/css">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="The Gentoo Devmanual is a technical manual which covers topics such as writing ebuilds and eclasses, and policies that developers should be abiding by.">
+ <link href="https://assets.gentoo.org/tyrian/bootstrap.min.css" rel="stylesheet" media="screen">
+ <link href="https://assets.gentoo.org/tyrian/tyrian.min.css" rel="stylesheet" media="screen">
+ <link rel="icon" href="https://www.gentoo.org/favicon.ico" type="image/x-icon">
+</head>
+<body>
+<header><div class="site-title"><div class="container"><div class="row">
+<div class="site-title-buttons"><div class="btn-group btn-group-sm">
+<a href="https://get.gentoo.org/" role="button" class="btn get-gentoo"><span class="fa fa-fw fa-download"></span><strong> Get Gentoo!</strong></a><div class="btn-group btn-group-sm">
+<a class="btn gentoo-org-sites dropdown-toggle" data-toggle="dropdown" data-target="#" href="#"><span class="fa fa-fw fa-map-o"></span><span class="hidden-xs"> gentoo.org sites </span><span class="caret"></span></a><ul class="dropdown-menu dropdown-menu-right">
+<li><a href="https://www.gentoo.org/" title="Main Gentoo website"><span class="fa fa-home fa-fw"></span> gentoo.org</a></li>
+<li><a href="https://wiki.gentoo.org/" title="Find and contribute documentation"><span class="fa fa-file-text-o fa-fw"></span> Wiki</a></li>
+<li><a href="https://bugs.gentoo.org/" title="Report issues and find common issues"><span class="fa fa-bug fa-fw"></span> Bugs</a></li>
+<li><a href="https://forums.gentoo.org/" title="Discuss with the community"><span class="fa fa-comments-o fa-fw"></span> Forums</a></li>
+<li><a href="https://packages.gentoo.org/" title="Find software for your Gentoo"><span class="fa fa-hdd-o fa-fw"></span> Packages</a></li>
+<li class="divider">
+<li><a href="https://planet.gentoo.org/" title="Find out what's going on in the developer community"><span class="fa fa-rss fa-fw"></span> Planet</a></li>
+<li><a href="https://archives.gentoo.org/" title="Read up on past discussions"><span class="fa fa-archive fa-fw"></span> Archives</a></li>
+<li><a href="https://sources.gentoo.org/" title="Browse our source code"><span class="fa fa-code fa-fw"></span> Sources</a></li>
+<li class="divider">
+<li><a href="https://infra-status.gentoo.org/" title="Get updates on the services provided by Gentoo"><span class="fa fa-server fa-fw"></span> Infra Status</a></li>
+</ul>
+</div>
+</div></div>
+<div class="logo">
+<a href="/" title="Back to the homepage" class="site-logo"><object data="https://assets.gentoo.org/tyrian/site-logo.svg" type="image/svg+xml"><img src="https://assets.gentoo.org/tyrian/site-logo.png" alt="Gentoo Linux Logo"></object></a><span class="site-label">Development Guide</span>
+</div>
+</div></div></div>
+<nav class="tyrian-navbar" role="navigation"><div class="container"><div class="row">
+<div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main-collapse"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button></div>
+<div class="collapse navbar-collapse navbar-main-collapse"><ul class="nav navbar-nav">
+<li><a href="/index.html"><i class="fa fa-home"></i> Home</a></li>
+<li><a href="../index.html"><i class="fa fa-arrow-up"></i> Eclass Reference</a></li>
+</ul></div>
+</div></div></nav></header><div class="container"><div class="row"><div class="col-md010"><ol class="breadcrumb"><li><a href="/index.html">Master Index</a></li><li><a href="../index.html">Eclass Reference</a></li></ol></div></div></div>
+ <div class="container">
+EOF
+ # generate html pages and fix hyperlinks for eclass and ebuild man pages
+ /bin/bunzip2 -c $i | /usr/bin/man2html -r - | \
+ sed -e "/<A HREF=/s:=.*man.*/\(.*eclass\).*html\">:=../\1/index.html>:" \
+ -e "/<\/BODY>/d" -e "/<\/HTML>/d" \
+ -e "/<A HREF=/s:=.*man.*/\(.*ebuild\).*html\">:=../\1/\index.html>:" >> ${TMP}
+ # The first 4 lines are cruft for devmanual
+ tail -n $(($(wc -l ${TMP} | awk '{print $1}') - 4)) ${TMP} >> ${FINAL}
+ rm -f ${TMP}
+ echo "${FOOTER}" >> ${FINAL}
+done
+
+# Remove old dirs (eclasses that were dropped from the tree)
+find $OUTPUTDIR -mindepth 1 -maxdepth 1 -mtime +1 -exec rm -R {} \;
+
+# build the index, rebuilding it each time
+cat << EOF > $OUTPUTDIR/text.xml
+<?xml version="1.0"?>
+<guide self="eclass-reference/">
+<chapter>
+<title>Eclass Reference</title>
+
+<body>
+<p>
+This section provides a reference for some of the more commonly used eclasses.
+Note that most eclasses have an accompanying manual page. These man pages can be
+installed by emerging <code class="docutils literal"><span class="pre">app-portage/eclass-manpages</span></code>.
+</p>
+</body>
+
+<section>
+<title>Contents</title>
+<body>
+<ul>
+EOF
+
+for i in $(find $OUTPUTDIR/ -maxdepth 1 -mindepth 1 -type d | sort); do
+ echo "<li><uri link=\"::eclass-reference/$(basename $i)/index.html\">$(basename $i) Reference</uri></li>" >> ${OUTPUTDIR}/text.xml
+done
+
+cat << EOF >> ${OUTPUTDIR}/text.xml
+
+</ul></body>
+</section>
+</chapter>
+</guide>
+EOF
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] proj/devmanual:master commit in: /, bin/
@ 2019-03-22 18:51 Brian Evans
0 siblings, 0 replies; 10+ messages in thread
From: Brian Evans @ 2019-03-22 18:51 UTC (permalink / raw
To: gentoo-commits
commit: 534ad84860ac80c3984bf96a8b31a3c8c495b403
Author: Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 22 18:12:47 2019 +0000
Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Fri Mar 22 18:12:47 2019 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=534ad848
Add list-group attributes to some items
Signed-off-by: Brian Evans <grknight <AT> gentoo.org>
bin/gen-eclass-html.sh | 6 +++---
devbook.xsl | 21 +++++++++++++++------
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/bin/gen-eclass-html.sh b/bin/gen-eclass-html.sh
index e87f60f..f97f2c7 100755
--- a/bin/gen-eclass-html.sh
+++ b/bin/gen-eclass-html.sh
@@ -119,16 +119,16 @@ installed by emerging <code class="docutils literal"><span class="pre">app-porta
<section>
<title>Contents</title>
<body>
-<ul>
+<list-group-d>
EOF
for i in $(find $OUTPUTDIR/ -maxdepth 1 -mindepth 1 -type d | sort); do
- echo "<li><uri link=\"::eclass-reference/$(basename $i)/index.html\">$(basename $i) Reference</uri></li>" >> ${OUTPUTDIR}/text.xml
+ echo "<uri link=\"$(basename $i)/index.html\">$(basename $i) Reference</uri>" >> ${OUTPUTDIR}/text.xml
done
cat << EOF >> ${OUTPUTDIR}/text.xml
-</ul></body>
+</list-group-d></body>
</section>
</chapter>
</guide>
diff --git a/devbook.xsl b/devbook.xsl
index 2c8e506..4a47b6b 100644
--- a/devbook.xsl
+++ b/devbook.xsl
@@ -205,6 +205,14 @@
<ul><xsl:apply-templates/></ul>
</xsl:template>
+ <xsl:template match="list-group-d">
+ <div class="list-group"><xsl:apply-templates><xsl:with-param name="class">list-group-item</xsl:with-param></xsl:apply-templates></div>
+ </xsl:template>
+
+ <xsl:template match="list-group-u">
+ <ul class="list-group"><xsl:apply-templates><xsl:with-param name="class">list-group-item</xsl:with-param></xsl:apply-templates></ul>
+ </xsl:template>
+
<!-- Definition Lists -->
<xsl:template match="dl">
<dl><xsl:apply-templates/></dl>
@@ -279,6 +287,7 @@
</xsl:template>
<xsl:template match="uri">
+ <xsl:param name="class" />
<xsl:choose>
<xsl:when test="starts-with(@link, '::')">
<!-- Ideally we would work out how many levels to nest down to save a few bytes but
@@ -292,7 +301,7 @@
</xsl:variable>
<xsl:choose>
<xsl:when test="contains(@link, '##')">
- <a href="{concat($relative_path_depth_recursion, substring-after(substring-before(@link, '##'), '::'), '/index.html#', substring-after(@link, '##'))}"><xsl:value-of select="."/></a>
+ <a class="{$class}" href="{concat($relative_path_depth_recursion, substring-after(substring-before(@link, '##'), '::'), '/index.html#', substring-after(@link, '##'))}"><xsl:value-of select="."/></a>
</xsl:when>
<xsl:when test="contains(@link, '#')">
<xsl:variable name="anchor">
@@ -305,10 +314,10 @@
</xsl:variable>
<xsl:choose>
<xsl:when test=". != ''">
- <a href="{concat($relative_path_depth_recursion, substring-after(substring-before(@link, '#'), '::'), $slash, 'index.html#', $anchor)}"><xsl:value-of select="."/></a>
+ <a class="{$class}" href="{concat($relative_path_depth_recursion, substring-after(substring-before(@link, '#'), '::'), $slash, 'index.html#', $anchor)}"><xsl:value-of select="."/></a>
</xsl:when>
<xsl:otherwise>
- <a href="{concat($relative_path_depth_recursion, substring-after(substring-before(@link, '#'), '::'), $slash, 'index.html#', $anchor)}"><xsl:value-of select="substring-after(@link, '#')"/></a>
+ <a class="{$class}" href="{concat($relative_path_depth_recursion, substring-after(substring-before(@link, '#'), '::'), $slash, 'index.html#', $anchor)}"><xsl:value-of select="substring-after(@link, '#')"/></a>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
@@ -318,17 +327,17 @@
</xsl:variable>
<xsl:choose>
<xsl:when test=". != ''">
- <a href="{concat($relative_path_depth_recursion, substring-after(@link, '::'), $slash, 'index.html')}"><xsl:value-of select="."/></a>
+ <a class="{$class}" href="{concat($relative_path_depth_recursion, substring-after(@link, '::'), $slash, 'index.html')}"><xsl:value-of select="."/></a>
</xsl:when>
<xsl:otherwise>
- <a href="{concat($relative_path_depth_recursion, substring-after(@link, '::'), $slash, 'index.html')}"><xsl:value-of select="document(concat(/guide/@self, $relative_path_depth_recursion, substring-after(@link, '::'), '/text.xml'))/guide/chapter[1]/title"/></a>
+ <a class="{$class}" href="{concat($relative_path_depth_recursion, substring-after(@link, '::'), $slash, 'index.html')}"><xsl:value-of select="document(concat(/guide/@self, $relative_path_depth_recursion, substring-after(@link, '::'), '/text.xml'))/guide/chapter[1]/title"/></a>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
- <a href="{@link}"><xsl:value-of select="."/></a>
+ <a class="{$class}" href="{@link}"><xsl:value-of select="."/></a>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] proj/devmanual:master commit in: /, bin/
@ 2019-12-14 10:46 Ulrich Müller
0 siblings, 0 replies; 10+ messages in thread
From: Ulrich Müller @ 2019-12-14 10:46 UTC (permalink / raw
To: gentoo-commits
commit: 12fb6e610b2ed3f486ff3a6eb397f5eae0811e5d
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 11 10:02:20 2019 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Wed Dec 11 10:02:20 2019 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=12fb6e61
devbook.xsl: Support class="list-group" in <ul> element.
This replaces <list-group-d>, which was only used for the list of
eclasses. Remove <list-group-u> which was unused.
Update devbook.dtd and bin/gen-eclass-html.sh accordingly.
Generated output in eclass-reference/index.html is identical as
before, except for an (intentionally) removed empty line before the
closing </div>.
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
bin/gen-eclass-html.sh | 8 ++++----
devbook.dtd | 9 ++++-----
devbook.xsl | 24 +++++++++++++++---------
3 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/bin/gen-eclass-html.sh b/bin/gen-eclass-html.sh
index 9705d04..e7a72ab 100755
--- a/bin/gen-eclass-html.sh
+++ b/bin/gen-eclass-html.sh
@@ -135,16 +135,16 @@ installed by emerging <c>app-portage/eclass-manpages</c>.
<section>
<title>Contents</title>
<body>
-<list-group-d>
+<ul class="list-group">
EOF
for i in $(find $OUTPUTDIR/ -maxdepth 1 -mindepth 1 -type d | sort); do
- echo "<uri link=\"$(basename $i)/index.html\">$(basename $i) Reference</uri>" >> ${OUTPUTDIR}/text.xml
+ echo "<li><uri link=\"$(basename $i)/index.html\">$(basename $i) Reference</uri></li>" >> ${OUTPUTDIR}/text.xml
done
cat << EOF >> ${OUTPUTDIR}/text.xml
-
-</list-group-d></body>
+</ul>
+</body>
</section>
</chapter>
</guide>
diff --git a/devbook.dtd b/devbook.dtd
index 96d1c9d..dac1815 100644
--- a/devbook.dtd
+++ b/devbook.dtd
@@ -5,8 +5,7 @@
<!-- Based on common.dtd from GuideXML -->
<!ENTITY % block.class "p|pre|codesample|note|important|warning|todo
- |figure|table|ul|ol|dl
- |list-group-u|list-group-d">
+ |figure|table|ul|ol|dl">
<!ENTITY % inline.class "sup|sub|b|c|d|e|path|uri">
<!ENTITY % all.class "%block.class;|%inline.class;">
@@ -75,7 +74,10 @@
align (left|center|right) "left">
<!ELEMENT ul (li)+>
+<!ATTLIST ul class CDATA #IMPLIED>
+
<!ELEMENT ol (li)+>
+
<!ELEMENT li (#PCDATA|%all.class;)*>
<!ELEMENT dl (dt, dd)+>
@@ -83,9 +85,6 @@
<!-- The following is strange, but devbook.xsl expects only p elements -->
<!ELEMENT dd (p)+>
-<!ELEMENT list-group-u (#PCDATA|%all.class;)*>
-<!ELEMENT list-group-d (#PCDATA|%all.class;)*>
-
<!ELEMENT sup (#PCDATA|%inline.class;)*>
<!ELEMENT sub (#PCDATA|%inline.class;)*>
<!ELEMENT b (#PCDATA|%inline.class;)*>
diff --git a/devbook.xsl b/devbook.xsl
index cadd975..94cbf96 100644
--- a/devbook.xsl
+++ b/devbook.xsl
@@ -204,15 +204,21 @@
</xsl:template>
<xsl:template match="ul">
- <ul><xsl:apply-templates/></ul>
- </xsl:template>
-
- <xsl:template match="list-group-d">
- <div class="list-group"><xsl:apply-templates><xsl:with-param name="class">list-group-item</xsl:with-param></xsl:apply-templates></div>
- </xsl:template>
-
- <xsl:template match="list-group-u">
- <ul class="list-group"><xsl:apply-templates><xsl:with-param name="class">list-group-item</xsl:with-param></xsl:apply-templates></ul>
+ <xsl:choose>
+ <xsl:when test="@class='list-group'">
+ <div class="list-group">
+ <xsl:for-each select="li">
+ <xsl:apply-templates>
+ <xsl:with-param name="class">list-group-item</xsl:with-param>
+ </xsl:apply-templates>
+ <xsl:value-of select='$newline'/>
+ </xsl:for-each>
+ </div>
+ </xsl:when>
+ <xsl:otherwise>
+ <ul><xsl:apply-templates/></ul>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<!-- Definition Lists -->
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] proj/devmanual:master commit in: /, bin/
@ 2019-12-16 6:45 Ulrich Müller
0 siblings, 0 replies; 10+ messages in thread
From: Ulrich Müller @ 2019-12-16 6:45 UTC (permalink / raw
To: gentoo-commits
commit: 0563026d23083cf20fc446d5ac6f77dcdda1ff3d
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 16 06:43:11 2019 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Mon Dec 16 06:43:11 2019 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=0563026d
devbook.xsl: Add html lang attribute.
The W3 Validator wants to have this. Also add a newline after the
doctype declaration.
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
bin/gen-eclass-html.sh | 3 ++-
devbook.xsl | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/bin/gen-eclass-html.sh b/bin/gen-eclass-html.sh
index fe17064..e1f9e1f 100755
--- a/bin/gen-eclass-html.sh
+++ b/bin/gen-eclass-html.sh
@@ -6,7 +6,8 @@
OUTPUTDIR="eclass-reference"
IFS='' read -r -d '' HEADER << 'EOF'
-<!DOCTYPE html><html lang="en">
+<!DOCTYPE html>
+<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>@TITLE@ - Gentoo Development Guide</title>
diff --git a/devbook.xsl b/devbook.xsl
index aa93b75..96a0508 100644
--- a/devbook.xsl
+++ b/devbook.xsl
@@ -444,7 +444,8 @@
<xsl:template match="/">
<xsl:text disable-output-escaping='yes'><!DOCTYPE html></xsl:text>
- <html>
+ <xsl:value-of select='$newline'/>
+ <html lang="en">
<head>
<title><xsl:value-of select="/guide/chapter[1]/title"/> – Gentoo Development Guide</title>
<xsl:variable name="relative_path_depth" select="string-length(/guide/@self)-string-length(translate(/guide/@self, '/' , ''))"/>
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] proj/devmanual:master commit in: /, bin/
@ 2019-12-19 21:02 Göktürk Yüksek
0 siblings, 0 replies; 10+ messages in thread
From: Göktürk Yüksek @ 2019-12-19 21:02 UTC (permalink / raw
To: gentoo-commits
commit: 926e0d0855afa40f5dcbc16b1b7c66187afd7d73
Author: Göktürk Yüksek <gokturk <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 10 02:08:12 2019 +0000
Commit: Göktürk Yüksek <gokturk <AT> gentoo <DOT> org>
CommitDate: Thu Dec 19 20:58:02 2019 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=926e0d08
Rewrite the search functionality and extend the coverage
The current script only indexes the first <p> in a text.xml, and
sometimes only partially if the text is interrupted by another tag
such as <c/>.
Modify build_search_documents.py such that:
- It recursively traverses from chapter all the way down to
subsubsection
- Each <p>, <important>, <note>, <warning> is indexed separately
- In the search results, the match entry will have the title in the
form "Chapter[ -> Section[ -> Subsection[ -> Subsubsection]]]"
Modify search.js such that:
- The ref returned for a match is its index into "documents" array,
which makes it possible to retrieve the document in O(1).
Signed-off-by: Göktürk Yüksek <gokturk <AT> gentoo.org>
bin/build_search_documents.py | 112 ++++++++++++++++++++++++++++++++++++------
search.js | 22 ++++-----
2 files changed, 108 insertions(+), 26 deletions(-)
diff --git a/bin/build_search_documents.py b/bin/build_search_documents.py
index 9af2753..3816fdb 100755
--- a/bin/build_search_documents.py
+++ b/bin/build_search_documents.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
# Copyright 2019 Gentoo Authors
# Distributed under the terms of the GNU GPL version 2 or later
import json
@@ -6,19 +6,103 @@ import os.path
import sys
import xml.etree.ElementTree as ET
-files = sys.argv[1:]
-documents = []
-url_root = 'https://devmanual.gentoo.org/'
-for f in files:
- tree = ET.parse(f)
- root = tree.getroot()
- for chapter in root.findall('chapter'):
+def stringify_node(parent: ET.Element) -> str:
+ """Flatten this node and its immediate children to a string.
+
+ Combine the text and tail of this node, and any of its immediate
+ children, if there are any, into a flat string. The tag <d/> is a
+ special case that resolves to the dash ('-') character.
+
+ Keyword arguments:
+ parent -- the node to convert to a string
+
+ """
+ if parent.text:
+ text = parent.text.lstrip()
+ else:
+ text = str()
+
+ for child in parent.getchildren():
+ # The '<d/>' tag is simply a fancier '-' character
+ if child.tag == 'd':
+ text += '-'
+ if child.text:
+ text += child.text.lstrip()
+ if child.tail:
+ text += child.tail.rstrip()
+
+ text += parent.tail.rstrip()
+ return text.replace('\n', ' ')
+
+
+def process_node(documents: list, node: ET.Element, name: str, url: str) -> None:
+ """Recursively process a given node and its children based on tag values.
+
+ For the top level node <chapter>, extract the title and recurse
+ down to the children.
+ For the intermediary nodes with titles, such as <section>, update
+ the search result title and url, and recurse down.
+ For the terminal nodes, such as <p>, convert the contents of the
+ node to a string, and add it to the search documents.
+
+ Keyword arguments:
+ documents -- the search documents array
+ node -- the node to process
+ name -- the title to display for the search term match
+ url -- the url for the search term match in the document
+
+ """
+ if node.tag == 'chapter':
+ name = stringify_node(node.find('title'))
+
+ for child in node:
+ process_node(documents, child, name, url)
+ elif node.tag in ['section', 'subsection', 'subsubsection']:
+ title = stringify_node(node.find('title'))
+ name += ' -> ' + title
+ url = "{url_base}#{anchor}".format(
+ url_base=url.split('#')[0],
+ anchor=title.lower().replace(' ', '-'))
+
+ for child in node:
+ process_node(documents, child, name, url)
+ elif node.tag in ['body', 'guide']:
+ for child in node:
+ process_node(documents, child, name, url)
+ elif node.tag in ['p', 'important', 'note', 'warning']:
+ text = stringify_node(node)
+
+ documents.append({'id': len(documents),
+ 'name': name,
+ 'text': text,
+ 'url': url})
+ else:
+ pass
+
+
+def main(pathnames: list) -> None:
+ """The entry point of the script.
+
+ Keyword arguments:
+ pathnames -- a list of path names to process in sequential order
+ """
+ url_root = 'https://devmanual.gentoo.org/'
+ documents = []
+
+ for path in pathnames:
+ tree = ET.parse(path)
+ root = tree.getroot()
+
try:
- documents.append({"name": chapter.find('title').text,
- "text": chapter.find('body').find('p').text,
- "url": url_root + os.path.dirname(f) + '/'})
- except AttributeError:
- pass
+ url = url_root + os.path.dirname(path) + '/'
+
+ process_node(documents, root, None, url)
+ except:
+ raise
+
+ print('var documents = ' + json.dumps(documents) + ';')
+
-print('var documents = ' + json.dumps(documents) + ';')
+if __name__ in '__main__':
+ main(sys.argv[1:])
diff --git a/search.js b/search.js
index 0b9292f..ab28f87 100644
--- a/search.js
+++ b/search.js
@@ -5,9 +5,9 @@
"use strict";
var search_index = lunr(function () {
- this.ref('name');
+ this.ref('id');
this.field('text');
- this.field('url');
+ this.metadataWhitelist = ['position']
documents.forEach(function (doc) {
this.add(doc);
@@ -23,15 +23,13 @@ search_input.addEventListener("keyup", function(event) {
}
});
-function getContents(docs, article) {
- var contents = { text: "", url: "" };
+function getContents(docs, uid) {
+ var contents = { name: "", text: "", url: "" };
+
+ contents.name = docs[uid].name;
+ contents.text = docs[uid].text;
+ contents.url = docs[uid].url;
- for (var i = 0; i< docs.length; i++) {
- if (docs[i].name == article) {
- contents.text = docs[i].text;
- contents.url = docs[i].url;
- }
- }
return contents;
}
@@ -42,8 +40,8 @@ function search() {
if (results.length > 0) {
$("#searchResults .modal-body").empty();
$.each(results, function(index, result) {
- var title = result.ref;
- var contents = getContents(documents, title);
+ var uid = result.ref;
+ var contents = getContents(documents, uid);
$("#searchResults .modal-body").append(`<article><h5><a href="${contents.url}">
${title}</a></h5><p>${contents.text}</p></article>`);
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] proj/devmanual:master commit in: /, bin/
@ 2020-01-22 18:24 Ulrich Müller
0 siblings, 0 replies; 10+ messages in thread
From: Ulrich Müller @ 2020-01-22 18:24 UTC (permalink / raw
To: gentoo-commits
commit: 24bc25cc1e80f77924fabf5bbe7e4afeb1980716
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 18:06:39 2020 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 18:06:39 2020 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=24bc25cc
devbook.xsl: Load devmanual.css stylesheet last.
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
bin/gen-eclass-html.sh | 2 +-
devbook.xsl | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/bin/gen-eclass-html.sh b/bin/gen-eclass-html.sh
index 6ecfe9c..40f8490 100755
--- a/bin/gen-eclass-html.sh
+++ b/bin/gen-eclass-html.sh
@@ -11,11 +11,11 @@ IFS='' read -r -d '' HEADER << 'EOF'
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>@TITLE@ - Gentoo Development Guide</title>
- <link rel="stylesheet" href="../../devmanual.css" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="The Gentoo Devmanual is a technical manual which covers topics such as writing ebuilds and eclasses, and policies that developers should be abiding by.">
<link href="https://assets.gentoo.org/tyrian/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="https://assets.gentoo.org/tyrian/tyrian.min.css" rel="stylesheet" media="screen">
+ <link rel="stylesheet" href="../../devmanual.css" type="text/css">
<link rel="icon" href="https://www.gentoo.org/favicon.ico" type="image/x-icon">
</head>
<body>
diff --git a/devbook.xsl b/devbook.xsl
index 8d8d082..2bd73d8 100644
--- a/devbook.xsl
+++ b/devbook.xsl
@@ -449,11 +449,11 @@
<xsl:with-param name="append">../</xsl:with-param>
</xsl:call-template>
</xsl:variable>
- <link rel="stylesheet" href="{$relative_path_depth_recursion}devmanual.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="The Gentoo Devmanual is a technical manual which covers topics such as writing ebuilds and eclasses, and policies that developers should be abiding by." />
<link href="https://assets.gentoo.org/tyrian/bootstrap.min.css" rel="stylesheet" media="screen" />
<link href="https://assets.gentoo.org/tyrian/tyrian.min.css" rel="stylesheet" media="screen" />
+ <link rel="stylesheet" href="{$relative_path_depth_recursion}devmanual.css" type="text/css" />
<link rel="icon" href="https://www.gentoo.org/favicon.ico" type="image/x-icon" />
</head>
<body>
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] proj/devmanual:master commit in: /, bin/
@ 2020-02-28 6:26 Ulrich Müller
0 siblings, 0 replies; 10+ messages in thread
From: Ulrich Müller @ 2020-02-28 6:26 UTC (permalink / raw
To: gentoo-commits
commit: 2b33c9a170b122b6fd4ff33718698b25baaca889
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 25 16:27:04 2020 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri Feb 28 06:25:01 2020 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=2b33c9a1
bin/gen-eclass-html.sh: Use en-dash in page title.
For consistency with devbook.xsl. The literal character is visually
indistinguishable from other dashes when using a fixed-width font,
therefore replace it by an – escape.
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
bin/gen-eclass-html.sh | 2 +-
devbook.xsl | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/bin/gen-eclass-html.sh b/bin/gen-eclass-html.sh
index ed43090..88f05a0 100755
--- a/bin/gen-eclass-html.sh
+++ b/bin/gen-eclass-html.sh
@@ -10,7 +10,7 @@ IFS='' read -r -d '' HEADER << 'EOF'
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>@TITLE@ - Gentoo Development Guide</title>
+ <title>@TITLE@ – Gentoo Development Guide</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="The Gentoo Devmanual is a technical manual which covers topics such as writing ebuilds and eclasses, and policies that developers should be abiding by.">
<link href="https://assets.gentoo.org/tyrian/bootstrap.min.css" rel="stylesheet" media="screen">
diff --git a/devbook.xsl b/devbook.xsl
index 0fd8766..69a3b9a 100644
--- a/devbook.xsl
+++ b/devbook.xsl
@@ -452,7 +452,7 @@
<xsl:value-of select='$newline'/>
<html lang="en">
<head>
- <title><xsl:value-of select="/guide/chapter[1]/title"/> – Gentoo Development Guide</title>
+ <title><xsl:value-of select="/guide/chapter[1]/title"/> – Gentoo Development Guide</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="The Gentoo Devmanual is a technical manual which covers topics such as writing ebuilds and eclasses, and policies that developers should be abiding by." />
<xsl:choose>
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] proj/devmanual:master commit in: /, bin/
@ 2022-03-26 19:12 Ulrich Müller
0 siblings, 0 replies; 10+ messages in thread
From: Ulrich Müller @ 2022-03-26 19:12 UTC (permalink / raw
To: gentoo-commits
commit: e40ff7c7974e62e8be5a7edb4b53f2b3b0954ed7
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 26 19:12:38 2022 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Sat Mar 26 19:12:38 2022 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=e40ff7c7
Update copyright years
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
bin/gen-eclass-html.sh | 2 +-
devbook.xsl | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/bin/gen-eclass-html.sh b/bin/gen-eclass-html.sh
index 7274aa2..df759e0 100755
--- a/bin/gen-eclass-html.sh
+++ b/bin/gen-eclass-html.sh
@@ -75,7 +75,7 @@ IFS='' read -r -d '' FOOTER << 'EOF'
<li><a href="https://www.facebook.com/gentoo.org" title="Gentoo on Facebook"><span class="fa fa-facebook fa-fw"></span></a></li>
</ul></div>
<div class="col-xs-10 col-sm-9 col-md-10">
-<strong>Copyright (C) 2001-2021 Gentoo Authors</strong><br><small>
+<strong>Copyright (C) 2001-2022 Gentoo Authors</strong><br><small>
Gentoo is a trademark of the Gentoo Foundation, Inc.
The text of this document is distributed under the
<a href="https://www.gnu.org/licenses/gpl-2.0.html">GNU General Public License, version 2</a>.
diff --git a/devbook.xsl b/devbook.xsl
index bf68e9a..9a254a7 100644
--- a/devbook.xsl
+++ b/devbook.xsl
@@ -661,7 +661,7 @@
</xsl:if>
</div>
<div class="col-xs-10 col-sm-9 col-md-10">
- <strong>Copyright (C) 2001-2021 Gentoo Authors</strong><br />
+ <strong>Copyright (C) 2001-2022 Gentoo Authors</strong><br />
<small>
Gentoo is a trademark of the Gentoo Foundation, Inc.
The text of this document is distributed under the
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] proj/devmanual:master commit in: /, bin/
@ 2023-10-05 19:00 Ulrich Müller
0 siblings, 0 replies; 10+ messages in thread
From: Ulrich Müller @ 2023-10-05 19:00 UTC (permalink / raw
To: gentoo-commits
commit: 19153057c1dbbc3537dfc9d1ca20a12d69a46c81
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 2 10:53:27 2023 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Thu Oct 5 18:58:34 2023 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=19153057
devbook.xsl, bin/gen-eclass-html.sh: Link to privacy policy
Bug: https://bugs.gentoo.org/613938
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
bin/gen-eclass-html.sh | 9 +++++++--
devbook.xsl | 3 +++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/bin/gen-eclass-html.sh b/bin/gen-eclass-html.sh
index 7ace03b..74e25dc 100755
--- a/bin/gen-eclass-html.sh
+++ b/bin/gen-eclass-html.sh
@@ -70,10 +70,15 @@ IFS='' read -r -d '' FOOTER << 'EOF'
</div>
</div>
<div class="row">
-<div class="col-xs-2 col-sm-3 col-md-2"><ul class="footerlinks three-icons">
+<div class="col-xs-2 col-sm-3 col-md-2">
+<ul class="footerlinks three-icons">
<li><a href="https://twitter.com/gentoo" title="@Gentoo on Twitter"><span class="fa fa-twitter fa-fw"></span></a></li>
<li><a href="https://www.facebook.com/gentoo.org" title="Gentoo on Facebook"><span class="fa fa-facebook fa-fw"></span></a></li>
-</ul></div>
+</ul>
+<div class="text-center">
+<a href="https://wiki.gentoo.org/wiki/Foundation:Privacy_Policy">Privacy Policy</a>
+</div>
+</div>
<div class="col-xs-10 col-sm-9 col-md-10">
<strong>Copyright (C) 2001-2023 Gentoo Authors</strong><br><small>
Gentoo is a trademark of the Gentoo Foundation, Inc.
diff --git a/devbook.xsl b/devbook.xsl
index 7b6c734..d998710 100644
--- a/devbook.xsl
+++ b/devbook.xsl
@@ -658,6 +658,9 @@
<li><a href="https://twitter.com/gentoo" title="@Gentoo on Twitter"><span class="fa fa-twitter fa-fw"></span></a></li>
<li><a href="https://www.facebook.com/gentoo.org" title="Gentoo on Facebook"><span class="fa fa-facebook fa-fw"></span></a></li>
</ul>
+ <div class="text-center">
+ <a href="https://wiki.gentoo.org/wiki/Foundation:Privacy_Policy">Privacy Policy</a>
+ </div>
</xsl:if>
</div>
<div class="col-xs-10 col-sm-9 col-md-10">
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] proj/devmanual:master commit in: /, bin/
@ 2024-10-29 11:19 Ulrich Müller
0 siblings, 0 replies; 10+ messages in thread
From: Ulrich Müller @ 2024-10-29 11:19 UTC (permalink / raw
To: gentoo-commits
commit: f9abc1d4273dc6dc2a61e13105f435c61a8f24ba
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 29 11:17:18 2024 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Tue Oct 29 11:17:18 2024 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=f9abc1d4
bin/gen-eclass-html.sh: Add eclasses fallback for the offline version
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
Makefile | 2 +-
bin/gen-eclass-html.sh | 45 +++++++++++++++++++++++++++++++--------------
2 files changed, 32 insertions(+), 15 deletions(-)
diff --git a/Makefile b/Makefile
index 4fbbd90..a94361f 100644
--- a/Makefile
+++ b/Makefile
@@ -64,7 +64,7 @@ eclass-reference/text.xml:
@echo "Install app-doc/eclass-manpages and" >&2
@echo "run bin/gen-eclass-html.sh before calling make." >&2
@echo "Creating a placeholder index as fallback." >&2
- bin/gen-eclass-html.sh -n
+ OFFLINE="$(OFFLINE)" bin/gen-eclass-html.sh -n
appendices/todo-list/index.html: $(XMLS)
diff --git a/bin/gen-eclass-html.sh b/bin/gen-eclass-html.sh
index b17fbc5..9dd6a56 100755
--- a/bin/gen-eclass-html.sh
+++ b/bin/gen-eclass-html.sh
@@ -180,31 +180,48 @@ Note that most eclasses have an accompanying manual page. These man pages can be
installed by emerging <c>app-doc/eclass-manpages</c>.
</p>
-</body>
-
-<section>
-<title>Contents</title>
-<body>
EOF
-if [[ -n ${NOMAN} ]]; then
+if [[ -z ${NOMAN} ]]; then
+ cat <<- 'EOF' >> "${OUTPUTDIR}"/text.xml || exit 1
+ </body>
+
+ <section>
+ <title>Contents</title>
+ <body>
+
+ <ul class="list-group">
+ EOF
+ for i in $(find "${OUTPUTDIR}" -maxdepth 1 -mindepth 1 -type d | sort); do
+ echo "<li><uri link=\"$(basename $i)/index.html\">$(basename $i)</uri></li>" \
+ >> "${OUTPUTDIR}"/text.xml || exit 1
+ done
+ cat <<- 'EOF' >> "${OUTPUTDIR}"/text.xml || exit 1
+ </ul>
+ </body>
+ </section>
+ EOF
+elif [[ ${OFFLINE} -ne 0 ]]; then
+ # Offline version, absence of eclasses is expected => note
+ cat <<- 'EOF' >> "${OUTPUTDIR}"/text.xml || exit 1
+ <note>
+ The offline version of the devmanual does not include the documentation
+ for the eclasses.
+ </note>
+ </body>
+ EOF
+else
+ # Otherwise, presumably something went wrong => warning
cat <<- 'EOF' >> "${OUTPUTDIR}"/text.xml || exit 1
<warning>
This is only a placeholder. If you see this text in the output document,
then the eclass documentation is missing.
</warning>
+ </body>
EOF
-else
- echo '<ul class="list-group">' >> "${OUTPUTDIR}"/text.xml || exit 1
- for i in $(find "${OUTPUTDIR}" -maxdepth 1 -mindepth 1 -type d | sort); do
- echo "<li><uri link=\"$(basename $i)/index.html\">$(basename $i)</uri></li>" >> "${OUTPUTDIR}"/text.xml || exit 1
- done
- echo '</ul>' >> "${OUTPUTDIR}"/text.xml || exit 1
fi
cat << 'EOF' >> "${OUTPUTDIR}"/text.xml || exit 1
-</body>
-</section>
</chapter>
</guide>
EOF
^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-10-29 11:19 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-28 6:26 [gentoo-commits] proj/devmanual:master commit in: /, bin/ Ulrich Müller
-- strict thread matches above, loose matches on Subject: below --
2024-10-29 11:19 Ulrich Müller
2023-10-05 19:00 Ulrich Müller
2022-03-26 19:12 Ulrich Müller
2020-01-22 18:24 Ulrich Müller
2019-12-19 21:02 Göktürk Yüksek
2019-12-16 6:45 Ulrich Müller
2019-12-14 10:46 Ulrich Müller
2019-03-22 18:51 Brian Evans
2019-03-22 13:27 Brian Evans
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox