[Kimchi-devel] [PATCH 2/2] doc: Generate index.html to join all help pages

Sheldon shaohef at linux.vnet.ibm.com
Tue Feb 18 08:44:04 UTC 2014


On 02/18/2014 03:56 AM, Aline Manera wrote:
> From: Aline Manera <alinefm at br.ibm.com>

does the  UI page will get the help information for these help documents?

Such as:
________________________________________________________________________________
Name    CPU       Network I/O        Disk I/O        Livetile     Actions

When mouse hovers on CPU label, the Ui will get the CPU description from 
help/guests.html and
display it," Percentage of processor utilization in the virtual machine"

Also I want to know can we generate a help/guests.html stub from 
/#tabs/guests ?

or DITA is not easy to write and maintain.
Why we choose DITA? such as reStructuredText is more easy.

>
> This patch generates help/index.html automatically based on all .dita
> files during build time.
> For each dita file it generates a link on index.html
>
> Signed-off-by: Aline Manera <alinefm at br.ibm.com>
> ---
>   ui/pages/help/Makefile.am  |    3 ++-
>   ui/pages/help/gen-index.py |   64 ++++++++++++++++++++++++++++++++++++++++++++
>   2 files changed, 66 insertions(+), 1 deletion(-)
>   create mode 100755 ui/pages/help/gen-index.py
>
> diff --git a/ui/pages/help/Makefile.am b/ui/pages/help/Makefile.am
> index 81d7e90..5146692 100644
> --- a/ui/pages/help/Makefile.am
> +++ b/ui/pages/help/Makefile.am
> @@ -18,7 +18,7 @@
>   # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
>
>   DITA_HTML_FILES = $(patsubst %.dita,%.html,$(wildcard *.dita))
> -HTML_FILES = $(if $(wildcard *.html), $(wildcard *.html), $(DITA_HTML_FILES))
> +HTML_FILES = $(if $(wildcard *.html), $(wildcard *.html), $(DITA_HTML_FILES) index.html)
>   DITA_XSL_FILE = dita-help.xsl
>
>   helpdir = $(datadir)/kimchi/ui/pages/help
> @@ -27,5 +27,6 @@ dist_help_DATA = $(HTML_FILES) $(NULL)
>
>   %.html: %.dita $(DITA_XSL_FILE)
>   	xsltproc -o $@ $(DITA_XSL_FILE) $<
> +	$(shell pwd)/gen-index.py
>
>   CLEANFILES = $(HTML_FILES)
> diff --git a/ui/pages/help/gen-index.py b/ui/pages/help/gen-index.py
> new file mode 100755
> index 0000000..4fa7cbe
> --- /dev/null
> +++ b/ui/pages/help/gen-index.py
> @@ -0,0 +1,64 @@
> +#!/usr/bin/python
> +#
> +# Project Kimchi
> +#
> +# Copyright IBM, Corp. 2014
> +#
> +# Authors:
> +#  Aline Manera <alinefm at linux.vnet.ibm.com>
> +#
> +# This library is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU Lesser General Public
> +# License as published by the Free Software Foundation; either
> +# version 2.1 of the License, or (at your option) any later version.
> +#
> +# This library is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +# Lesser General Public License for more details.
> +#
> +# You should have received a copy of the GNU Lesser General Public
> +# License along with this library; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
> +
> +import glob
> +import libxml2
> +
> +
> +HTML_HEAD = """
> +<html>
> +<head>
> +  <title>Kimchi Help</title>
> +</head>
> +<body>
> +<h1>Kimchi Help</h1>
> +"""
> +
> +HTML_TAIL = """
> +</body>
> +</html>
> +"""
> +
> +
> +def main():
> +    pages = {}
> +    files = sorted(glob.glob('*.dita'))
> +    for f in files:
> +        with open(f) as fd:
> +            xml = fd.read()
> +            doc = libxml2.parseDoc(xml)
> +            node = doc.xpathEval('/cshelp/title')[0]
> +            name = node.children.content
> +            pages[f.replace('.dita', '.html')] = name
> +            doc.freeDoc()
> +
> +    with open('index.html', 'w') as fd:
> +        fd.write(HTML_HEAD)
> +        for page, name in pages.iteritems():
> +            html = '  <a href="/help/%s">%s</a><br />\n'
> +            fd.write(html % (page, name))
> +        fd.write(HTML_TAIL)
> +
> +
> +if __name__ == '__main__':
> +    main()


-- 
Thanks and best regards!

Sheldon Feng(???)<shaohef at linux.vnet.ibm.com>
IBM Linux Technology Center

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/kimchi-devel/attachments/20140218/7b007c0a/attachment.html>


More information about the Kimchi-devel mailing list