summaryrefslogtreecommitdiffstats
path: root/Doc/tools
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1999-04-22 13:08:09 (GMT)
committerFred Drake <fdrake@acm.org>1999-04-22 13:08:09 (GMT)
commit693a2c65812eb61a87cacf1a23b83db35bbf9552 (patch)
treeb3cb550bf33c9bff4da69505387d785e09769406 /Doc/tools
parente0208cc83cbc91bca0eb802b540c45a430399ef5 (diff)
downloadcpython-693a2c65812eb61a87cacf1a23b83db35bbf9552.zip
cpython-693a2c65812eb61a87cacf1a23b83db35bbf9552.tar.gz
cpython-693a2c65812eb61a87cacf1a23b83db35bbf9552.tar.bz2
Script to locate uses of \module where the module referred to is not
the module being documented at that point in the documentation; these are candidates for conversion to \refmodule, which produces a hyperlink in the HTML and PDF versions of the output.
Diffstat (limited to 'Doc/tools')
-rwxr-xr-xDoc/tools/findmodrefs45
1 files changed, 45 insertions, 0 deletions
diff --git a/Doc/tools/findmodrefs b/Doc/tools/findmodrefs
new file mode 100755
index 0000000..c055686
--- /dev/null
+++ b/Doc/tools/findmodrefs
@@ -0,0 +1,45 @@
+#! /usr/bin/env python
+# -*- Python -*-
+
+import fileinput
+import glob
+import os
+import re
+import sys
+
+
+declare_rx = re.compile(
+ r"\\declaremodule(?:\[[a-zA-Z0-9]*\]*)?{[a-zA-Z_0-9]+}{([a-zA-Z_0-9]+)}")
+
+module_rx = re.compile(r"\\module{([a-zA-Z_0-9]+)}")
+
+def main():
+ try:
+ files = sys.argv[1:]
+ if not files:
+ files = glob.glob("*.tex")
+ files.sort()
+ modulename = None
+ for line in fileinput.input(files):
+ if line[:9] == r"\section{":
+ modulename = None
+ continue
+ if line[:16] == r"\modulesynopsys{":
+ continue
+ m = declare_rx.match(line)
+ if m:
+ modulename = m.group(1)
+ continue
+ if not modulename:
+ continue
+ m = module_rx.search(line)
+ if m:
+ name = m.group(1)
+ if name != modulename:
+ print "%s:%s" % (fileinput.filename(), line[:-1])
+ except KeyboardInterrupt:
+ sys.exit(1)
+
+
+if __name__ == "__main__":
+ main()