Skip to content

Commit 88c274d

Browse files
committed
Machinery for sorting xrefs in the See Also sections.
1 parent be4baff commit 88c274d

File tree

4 files changed

+110
-59
lines changed

4 files changed

+110
-59
lines changed

DISCUSSIONS/common/menu/api_listing.xml

-52
This file was deleted.

Makefile

+14-6
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@
77
# set to ~/Sites. If you don't have a local server, set OOFWEBDIR to
88
# any empty writable directory outside of tmpdir.
99

10+
# All xml files that are *not* part of the reference section generated
11+
# by OOF2's xmlmenudump need to be listed in the file xmlfilelist in
12+
# this directory. The list needs to be in the order in which the
13+
# files are included in the main document. This ordering is used in
14+
# the "See Also" sections of the reference pages. If it's wrong, some
15+
# pages will be less pretty.
16+
1017
# "make local" generates html from the xml source files, using the xml
1118
# tools, and then wraps the html output in NIST boilerplate and puts
1219
# it in OOFWEBDIR/oof2man.
1320

1421
# "make publish" copies the local output to the CTCMS web server.
1522

16-
XMLFILES = CH_graphics.xml CH_tasks.xml CH_windows.xml SN_skel.xml \
17-
man_oof2.xml oof2_api.xml CH_overview.xml CH_concepts.xml SN_micro.xml
18-
1923
# On macOS with macports, dvi2bitmap needs to be built with
2024
# --with-kpathsea --enable-fontgen
2125

@@ -26,6 +30,10 @@ DVI2BITMAP = dvi2bitmap --magnification=5 --scaledown=4 --output-type=gif --font
2630
# mktexpk if it's not using kpathsea.
2731
TEMPDIR = tmpdir
2832

33+
# There's no need to explicitly list all of the xml files in the
34+
# dependencies. They're included by man_oof2.xml, which depends on
35+
# oof2_api.xml, and oof2_api.ml is always rebuilt.
36+
2937
SAXON = ../xsl/java/saxon.jar
3038
## TODO: More up-to-date saxon from MacPorts raises lots of warnings
3139
## and errors. Is there any point in updating?
@@ -61,11 +69,11 @@ oof2man.tgz: $(TEMPDIR) saxonize.ext texify figs
6169
tar -czf oof2man.tgz oof2man
6270
-rm -rf oof2man
6371

64-
saxonize.web: $(XMLFILES)
72+
saxonize.web: oof2_api.xml
6573
mkdir $(TEMPDIR)/equations
6674
(cd $(TEMPDIR); rm -f *.html; java -jar $(SAXON) ../man_oof2.xml ../xsl/oofchunk.xsl nist.exit.script=1)
6775

68-
saxonize.ext: $(XMLFILES)
76+
saxonize.ext: oof2_api.xml
6977
(cd $(TEMPDIR); rm -f *.html; java -jar $(SAXON) ../man_oof2.xml ../xsl/oofchunk.xsl)
7078

7179
texify:
@@ -75,7 +83,7 @@ texify:
7583
oof2: always
7684
(cd build; make -j 10 DESTDIR=~/stow/oof2-py311 install; cd ~/stow; ./switchto oof2-py311)
7785

78-
oof2_api.xml: oof2
86+
oof2_api.xml: oof2 xmlfilelist
7987
bin/oof2 --script xmldump.py --quiet --debug
8088
sed s/Graphics_1/Graphics_n/g oof2_api.xml > tmp
8189
mv -f tmp oof2_api.xml

xmldump.py

+39-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,45 @@
1212
# and RegisteredClasses, and some other bits and pieces.
1313

1414
# Some menus aren't constructed until a graphics window is opened.
15+
1516
OOF.Windows.Graphics.New()
1617

17-
OOF.Help.API_Listing(filename='oof2_api.xml', format='xml')
18+
# Get the ids from the xml files other than oof2_api.xml. This lets
19+
# the code in SRC/common/IO/xmlmenudump.py sort cross references in
20+
# oof2_api.xml in a sensible way.
21+
22+
import re
23+
# Regexp pattern that matches id="idtag" or id='idtag'. It defines
24+
# two groups. This first is just the opening quotation mark, which is
25+
# in a group so that it can be compared to the closing quotation mark.
26+
# The second group is the idtag.
27+
pattern = re.compile(r"""id=(["'])(.+?)\1""")
28+
29+
xmlids = {} # xmlids[id] = order
30+
sourcefiles = open("xmlfilelist", "r")
31+
for fline in sourcefiles:
32+
filename = fline.strip()
33+
if filename and filename[0] != '#':
34+
srcfile = open(filename, "r")
35+
for srcline in srcfile:
36+
# This might include commented out lines, but that
37+
# shouldn't matter. Adding them to the dict won't change
38+
# the ordering of the other ids.
39+
for r in pattern.findall(srcline):
40+
# findall returns a list of strings that match the two
41+
# groups defined in the regexp pattern. The second
42+
# group is the docbook id.
43+
xmlids[r[1]] = len(xmlids)
44+
45+
# Don't use an OOF2 menu item to generate the manual. It's not
46+
# something that users will do, and not something that needs to be
47+
# logged. Also, xmlids is too large to use as an OOFMenuItem
48+
# argument, since it will be echoed to the screen. Just call
49+
# xmlmenudump directly.
50+
51+
from ooflib.common.IO import xmlmenudump
52+
outfile = open('oof2_api.xml', 'w')
53+
xmlmenudump.xmlmenudump(outfile, xmlids)
54+
outfile.close()
55+
1856
OOF.File.Quit()

xmlfilelist

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# This software was produced by NIST, an agency of the U.S. government,
2+
# and by statute is not subject to copyright in the United States.
3+
# Recipients of this software assume all responsibilities associated
4+
# with its operation, modification and maintenance. However, to
5+
# facilitate maintenance we ask that before distributing modified
6+
# versions of this software, you first contact the authors at
7+
8+
9+
# This file lists the xml source files used to build the oof2 manual,
10+
# in the order in which they're imported. It's used to build a table
11+
# of xml ids so that xmldump.py can create sensible cross references.
12+
13+
# This list does not include oof2_api.xml or the files that are used
14+
# to create it. The list is used before oof2_api.xml is generated.
15+
16+
# Blank lines and lines beginning with '#' are ignored.
17+
18+
CH_overview.xml
19+
CH_starting.xml
20+
CH_concepts.xml
21+
22+
CH_tasks.xml
23+
# CH_tasks includes:
24+
SN_micro.xml
25+
SN_image.xml
26+
SN_pixelsel.xml
27+
SN_active.xml
28+
SN_material.xml
29+
# SN_interfaces.xml (commented out until the interface branch is complete)
30+
SN_skel.xml
31+
SN_pinnodes.xml
32+
SN_skelsel.xml
33+
SN_skelbdy.xml
34+
SN_femesh.xml
35+
SN_fields.xml
36+
SN_bdycond.xml
37+
SN_scheduledout.xml
38+
SN_solver.xml
39+
SN_analysis.xml
40+
SN_bdyanalysis.xml
41+
42+
CH_graphics.xml
43+
# CH_graphics includes:
44+
TB_viewer.xml
45+
TB_pixelinfo.xml
46+
TB_pixelsel.xml
47+
TB_skelinfo.xml
48+
TB_skelselection.xml
49+
TB_movenodes.xml
50+
TB_pinnodes.xml
51+
TB_meshinfo.xml
52+
TB_meshcs.xml
53+
54+
CH_windows.xml
55+
CH_extending.xml
56+
CH_coding.xml
57+
appendices.xml

0 commit comments

Comments
 (0)