pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/doc/guide
Module Name: pkgsrc
Committed By: rillig
Date: Mon Apr 29 16:18:41 UTC 2019
Modified Files:
pkgsrc/doc/guide: Makefile
Added Files:
pkgsrc/doc/guide/files: help-topics.gen.py
Removed Files:
pkgsrc/doc/guide/files: generate-help-topics.pl
Log Message:
doc/guide: use Python instead of Perl for autogenerating help topics
The code is shorter and there's less line noise.
To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 pkgsrc/doc/guide/Makefile
cvs rdiff -u -r1.1 -r0 pkgsrc/doc/guide/files/generate-help-topics.pl
cvs rdiff -u -r0 -r1.1 pkgsrc/doc/guide/files/help-topics.gen.py
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/doc/guide/Makefile
diff -u pkgsrc/doc/guide/Makefile:1.53 pkgsrc/doc/guide/Makefile:1.54
--- pkgsrc/doc/guide/Makefile:1.53 Sun Apr 28 15:22:24 2019
+++ pkgsrc/doc/guide/Makefile Mon Apr 29 16:18:41 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.53 2019/04/28 15:22:24 rillig Exp $
+# $NetBSD: Makefile,v 1.54 2019/04/29 16:18:41 rillig Exp $
DISTNAME= pkgsrc-guide-${PKGVERSION}
CATEGORIES= # empty
@@ -16,7 +16,6 @@ PKGVERSION!= date '+%Y%m%d'
DIST_SUBDIR= ${PKGBASE}
USE_LANGUAGES= # empty
MAKE_ENV+= SED=${SED:Q}
-USE_TOOLS+= perl
PLIST_VARS= ascii html pdf
@@ -64,10 +63,10 @@ pre-extract:
${MKDIR} ${WRKSRC}
${LN} -s ${FILESDIR}/* ${WRKSRC}
-post-extract: generate-help-topics
+pre-configure: generate-help-topics
generate-help-topics: .PHONY
${RUN} ${MAKE} help topic=:index > ${WRKSRC}/help-topics.data
- ${RUN} cd ${WRKSRC} && perl generate-help-topics.pl
+ ${RUN} cd ${WRKSRC} && python help-topics.gen.py
do-build:
.for _output_ in ${OUTPUTS}
@@ -157,4 +156,6 @@ htdocs-share:
-s ',^,htdocs/,' \
global.css share
+PYTHON_FOR_BUILD_ONLY= tool
+.include "../../lang/python/tool.mk"
.include "../../mk/bsd.pkg.mk"
Added files:
Index: pkgsrc/doc/guide/files/help-topics.gen.py
diff -u /dev/null pkgsrc/doc/guide/files/help-topics.gen.py:1.1
--- /dev/null Mon Apr 29 16:18:41 2019
+++ pkgsrc/doc/guide/files/help-topics.gen.py Mon Apr 29 16:18:41 2019
@@ -0,0 +1,31 @@
+#! python
+# $NetBSD: help-topics.gen.py,v 1.1 2019/04/29 16:18:41 rillig Exp $
+
+import os
+
+tmpl_file = "help-topics.tmpl.xml"
+data_file = "help-topics.data"
+out_file = "help-topics.xml"
+
+
+def merge():
+ def read_lines(filename):
+ with open(filename) as f:
+ return f.readlines()
+
+ out = []
+ for tmpl_line in read_lines(tmpl_file):
+ if '@topic@' in tmpl_line:
+ for topic in read_lines(data_file)[2:]:
+ xml_topic = topic.replace('&', '%amp;').replace('<', '<')
+ out.append(tmpl_line.replace('@topic@', xml_topic))
+ else:
+ out.append(tmpl_line)
+
+ with open(f'{out_file}.tmp', 'w') as f:
+ f.writelines(out)
+ os.rename(f'{out_file}.tmp', out_file)
+
+
+if __name__ == '__main__':
+ merge()
Home |
Main Index |
Thread Index |
Old Index