[PATCH 0/2] Fix help Makefile

Tested on Fedora 20. Crístian Viana (2): fix: Build new DITA pages when running "make" Build help index page only once ui/pages/help/Makefile.am | 6 ++++-- ui/pages/help/gen-index.py | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) -- 1.8.5.3

When the user types "make" for the first time, all the .dita files are converted to .html. But if some new DITA page is added to the directory, it is not build. The user has to remove all HTML files and run "make" again. Update the Makefile so it can build new DITA files if any is added Signed-off-by: Crístian Viana <vianac@linux.vnet.ibm.com> --- ui/pages/help/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/pages/help/Makefile.am b/ui/pages/help/Makefile.am index 78b6b99..97011f4 100644 --- a/ui/pages/help/Makefile.am +++ b/ui/pages/help/Makefile.am @@ -15,7 +15,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) index.html) +HTML_FILES = $(if $(DITA_HTML_FILES), $(DITA_HTML_FILES) index.html, $(wildcard *.html)) DITA_XSL_FILE = dita-help.xsl helpdir = $(datadir)/kimchi/ui/pages/help -- 1.8.5.3

The help index page (ui/pages/help/index.html) is being built once for every .dita file available. I.e. if there are 10 .dita files, 10 .html files are generated and index.html is generated 10 times. Improve the Makefile target so it generates the help index page only once whenever one of the .dita file changes. The build Python script has also been updated so its input and output are more flexible, making it easier to handle from the Makefile. Signed-off-by: Crístian Viana <vianac@linux.vnet.ibm.com> --- ui/pages/help/Makefile.am | 4 +++- ui/pages/help/gen-index.py | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ui/pages/help/Makefile.am b/ui/pages/help/Makefile.am index 97011f4..719f603 100644 --- a/ui/pages/help/Makefile.am +++ b/ui/pages/help/Makefile.am @@ -24,8 +24,10 @@ dist_help_DATA = $(HTML_FILES) $(NULL) EXTRA_DIST = $(wildcard *.dita) +index.html: $(wildcard *.dita) + $(shell pwd)/gen-index.py $^ > $@ + %.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 index e62b608..56cbf47 100755 --- a/ui/pages/help/gen-index.py +++ b/ui/pages/help/gen-index.py @@ -20,6 +20,7 @@ import glob import libxml2 +import sys HTML_HEAD = """ @@ -38,9 +39,13 @@ HTML_TAIL = """ def main(): + if len(sys.argv) < 2: + sys.exit("Missing input files") + + input_files = sys.argv[1:] + pages = {} - files = sorted(glob.glob('*.dita')) - for f in files: + for f in sorted(input_files): with open(f) as fd: xml = fd.read() doc = libxml2.parseDoc(xml) @@ -49,12 +54,11 @@ def main(): 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) + print HTML_HEAD + for page, name in pages.iteritems(): + html = ' <a href="/help/%s">%s</a><br />\n' + print html % (page, name) + print HTML_TAIL if __name__ == '__main__': -- 1.8.5.3

Reviewed-by: Aline Manera <alinefm@linux.vnet.ibm.com> On 03/07/2014 05:46 PM, Crístian Viana wrote:
Tested on Fedora 20.
Crístian Viana (2): fix: Build new DITA pages when running "make" Build help index page only once
ui/pages/help/Makefile.am | 6 ++++-- ui/pages/help/gen-index.py | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-)
participants (2)
-
Aline Manera
-
Crístian Viana