Received: by mail.netbsd.org (Postfix, from userid 605) id 1E1C384DF6; Mon, 29 Apr 2019 16:18:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id 885D484DF3 for ; Mon, 29 Apr 2019 16:18:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([127.0.0.1]) by localhost (mail.netbsd.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id ozwlP3A1XaQy for ; Mon, 29 Apr 2019 16:18:42 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.NetBSD.org [IPv6:2001:470:a085:999:28c:faff:fe03:5984]) by mail.netbsd.org (Postfix) with ESMTP id 0660C84D95 for ; Mon, 29 Apr 2019 16:18:42 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 015A5FB16; Mon, 29 Apr 2019 16:18:41 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_1556554721292000" MIME-Version: 1.0 Date: Mon, 29 Apr 2019 16:18:41 +0000 From: "Roland Illig" Subject: CVS commit: pkgsrc/doc/guide To: pkgsrc-changes@NetBSD.org Reply-To: rillig@netbsd.org X-Mailer: log_accum Message-Id: <20190429161842.015A5FB16@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: pkgsrc-changes.NetBSD.org Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_1556554721292000 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" 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. --_----------=_1556554721292000 Content-Disposition: inline Content-Length: 2277 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=us-ascii 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() --_----------=_1556554721292000--