From 22fe5b07601749f85a5250b0f537b71cea46d50f Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 14 Apr 2017 01:50:13 -0700 Subject: [PATCH] doc: generate proper XHTML for the contents and index The table of contents and index needed rework to be valid (X)HTML. The TOC in particular needed some fairly significant rework - it is supposed to be an ordered list, after all. Signed-off-by: H. Peter Anvin --- doc/Makefile.in | 8 ++++--- doc/nasmdoc.css | 21 ++++++++++++++++++ doc/rdsrc.pl | 68 ++++++++++++++++++++++++++++++++++++--------------------- 3 files changed, 69 insertions(+), 28 deletions(-) diff --git a/doc/Makefile.in b/doc/Makefile.in index cc6969ec..ac091e99 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -25,8 +25,7 @@ RM_F = rm -f RM_RF = rm -rf CP_F = cp -f -SRCS = nasmdoc.src inslist.src changes.src version.src \ - nasmdoc.css nasmlogw.png +SRCS = nasmdoc.src inslist.src changes.src version.src OUT = html nasmdoc.txt nasmdoc.pdf .SUFFIXES: .pfa .ph @@ -37,11 +36,14 @@ inslist.src: inslist.pl ../x86/insns.dat $(PERL) $(srcdir)/inslist.pl $(srcdir)/../x86/insns.dat .PHONY: html -html: html/nasmdoc0.html html/nasmdoc.css html/nasmlogw.png +html: $(SRCS) rdsrc.pl nasmdoc.css nasmlogw.png + mkdir -p html + $(MAKE) html/nasmdoc0.html html/nasmdoc.css html/nasmlogw.png RDSRC = $(PERL) $(srcdir)/rdsrc.pl -I$(srcdir)/ html/nasmdoc0.html: $(SRCS) rdsrc.pl + $(RM_F) html/*.html $(RDSRC) -ohtml html nasmdoc.src html/nasmdoc.css: nasmdoc.css diff --git a/doc/nasmdoc.css b/doc/nasmdoc.css index 21f08d53..8c8e378f 100644 --- a/doc/nasmdoc.css +++ b/doc/nasmdoc.css @@ -20,6 +20,27 @@ code { a { text-decoration: none; } +div.toc { + padding-left: 0; + font-size: 195%; +} +div.toc li { + list-style-type: none; + padding-left: 0; +} +div.toc ol { + padding-left: 2em; + font-size: 80%; +} +li.toc1 { + padding-top: 0.7em; +} +li.toc2 { + padding-top: 0.3em; +} +ul.index { + list-style-type: none; +} @media not screen { ul.navbar { display: none; diff --git a/doc/rdsrc.pl b/doc/rdsrc.pl index afe93d68..719e9b2d 100644 --- a/doc/rdsrc.pl +++ b/doc/rdsrc.pl @@ -745,31 +745,48 @@ sub write_html { select TEXT; &html_preamble(0); print "

This manual documents NASM, the Netwide Assembler: an assembler\n"; - print "targetting the Intel x86 series of processors, with portable source.\n"; - print "

"; + print "targetting the Intel x86 series of processors, with portable source.\n

"; + print "
\n"; + $level = 0; for ($node = $tstruct_next{'Top'}; $node; $node = $tstruct_next{$node}) { - if ($tstruct_level{$node} == 1) { + my $lastlevel = $level; + while ($tstruct_level{$node} < $level) { + print "\n\n"; + $level--; + } + while ($tstruct_level{$node} > $level) { + print "
    \n"; + } + if ($lastlevel >= $level) { + print "\n"; + } + $level = $tstruct_level{$node}; + if ($level == 1) { # Invent a file name. - ($number = lc($xrefnodes{$node})) =~ s/.*-//; - $fname="nasmdocx.html"; - substr($fname,8 - length $number, length $number) = $number; - $html_fnames{$node} = $fname; - $link = $fname; - print "

    "; - } else { - # Use the preceding filename plus a marker point. - $link = $fname . "#$xrefnodes{$node}"; - } - $title = "$node: "; - $pname = $tstruct_pname{$node}; - foreach $i (@$pname) { - $ww = &word_html($i); - $title .= $ww unless $ww eq "\001"; - } - print "$title
    \n"; + ($number = lc($xrefnodes{$node})) =~ s/.*-//; + $fname="nasmdocx.html"; + substr($fname,8 - length $number, length $number) = $number; + $html_fnames{$node} = $fname; + $link = $fname; + } else { + # Use the preceding filename plus a marker point. + $link = $fname . "#$xrefnodes{$node}"; + } + $title = ''; + $pname = $tstruct_pname{$node}; + foreach $i (@$pname) { + $ww = &word_html($i); + $title .= $ww unless $ww eq "\001"; + } + print "

  1. \n"; + print "$node: $title\n"; } - print "

    Index\n"; - print "\n"; + while ($level--) { + print "

  2. \n
\n"; + } + print "
\n"; + print "\n"; + print "\n"; select STDOUT; close TEXT; @@ -915,7 +932,7 @@ sub write_html { open TEXT, '>', File::Spec->catfile($out_path, 'nasmdoci.html'); select TEXT; &html_preamble(0); - print "

Index

\n"; + print "

Index

\n"; print "\n\n\n"; @@ -961,6 +978,7 @@ sub html_index { push @a, "sp", "x $xrefnodes{$node}", "n $node", "xe$xrefnodes{$node}"; $sep = 1; } + print "
  • \n"; $line = ''; do { do { $w = &word_html(shift @a) } while $w eq "\001"; # nasty hack @@ -979,9 +997,9 @@ sub html_index { } while ($w ne '' && $w ne undef); if ($line =~ /\S/) { $line =~ s/\s*$//; # trim trailing spaces - print "$line\n"; + print $line, "\n"; } - print "
    \n"; + print "
  • \n"; } } -- 2.11.4.GIT