diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2021-04-25 01:07:14 +0200 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2021-04-25 02:21:05 +0200 |
commit | 58510024bead8df9cba6e316f8275423a38fd51b (patch) | |
tree | bc61b5c01359b0b7ef62624f9ed7c21e129a9e5c /tools/linuxdoc-tools/LinuxDocTools/FixRef.pm | |
parent | b646c0098120bbb10ec91fa2fbf1df416c5849bd (diff) |
Doc: Include full LinuxDocTools code
BIRD uses hacked LinuxDocTools for building documentation, keeping some
parts locally and using remaining parts from system-installed one. This
setup breaks when LinuxDocTools makes some internal changes and is hard
to keep consistent.
Just include full LinuxDocTools code (both hacked and unmodified parts)
to avoid consistency issues. Note that we still need some binaries from
LinuxDocTools, so it still needs to be installed to build documentation.
Diffstat (limited to 'tools/linuxdoc-tools/LinuxDocTools/FixRef.pm')
-rw-r--r-- | tools/linuxdoc-tools/LinuxDocTools/FixRef.pm | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tools/linuxdoc-tools/LinuxDocTools/FixRef.pm b/tools/linuxdoc-tools/LinuxDocTools/FixRef.pm new file mode 100644 index 00000000..d2549857 --- /dev/null +++ b/tools/linuxdoc-tools/LinuxDocTools/FixRef.pm @@ -0,0 +1,76 @@ +# +# FixRef.pm +# +# $Id: FixRef.pm,v 1.1.1.1 2001/05/24 15:57:41 sano Exp $ +# +# Start conversion from parsed linuxdoc-sgml to html. +# - Identify references and file count +# +# Rules based on fixref.l +# +package LinuxDocTools::FixRef; + +# Externally visible variables +$fixref = {}; + +# Initialize: set splitlevel before using rules +# Usage: &{$fixref->{init}}(<split level>); + # 0 - super page mode + # 1 - big page mode + # 2 - small page mode +$fixref->{init} = sub { + $splitlevel = shift; +}; + +# Outputs: Read after using rules +$fixref->{filenum} = 0; # Count of files we will create +$fixref->{lrec} = {}; # label -> filenum + +# Package variables +$chapter_mode = 0; # <report> vs. <article> +$splitlevel = 0; # See $fixref->{init} above; + # Automatically reduced by 1 for chapter mode + +# Finalize parsing +$fixref->{finish} = sub { }; # Do nothing when we're done + +# Ruleset +$fixref->{rules} = {}; # Individual parsing rules +$fixref->{defaultrule} = sub { }; # If line does not match any rules + +# Set the rules +# <@@ssect> - split file if necessary +$fixref->{rules}->{'^<@@ssect>.*$'} = sub { &splitfile(2); }; + +# <@@sect> - split file if necessary +$fixref->{rules}->{'^<@@sect>.*$'} = sub { &splitfile(1); }; + +# <@@chapt> - set chapter mode; reduce splitlevel if needed; split file +$fixref->{rules}->{'^<@@chapt>.*$'} = sub { + $splitlevel-- if (!$chapter_mode); + $chapter_mode = 1; &splitfile(0); +}; + +# <@@label> - Identify label location +$fixref->{rules}->{'^<@@label>(.*)$'} = sub { + $fixref->{lrec}->{$1} = $fixref->{filenum}; +}; + +#============================== +# Split the file (-split option; level in parentheses): +# non-chapter mode: -0 -> don't split +# -1 -> split at sect (1) +# -2 -> split at sect (1) and ssect (2) +# chapter mode: -0 -> split at chapt (0) +# -1 -> split at chapt (0) +# -2 -> split at chapt (0) and sect (1) +sub splitfile +{ + my ($level) = @_; + if (($level == 0) || ($splitlevel >= $level)) { + $fixref->{filenum}++; + } +} + +1; + |