binutils-gdb/bfd/sedscript

86 lines
2.4 KiB
Plaintext
Executable File

# SED script for preprocessing embedded doc from source (S. Chamberlain markup)
# middle pass; most of the work is done here.
#
# First, get rid of /*doc* markers; they've done their job in the first pass.
/^\/\*doc\*/d
#
# /*proto* markers may be optionally followed by a *i-style subsubsec, findex
# entry. This will generate empty @findex and @subsubsection entries if
# the *proto* is on a line by itself; third pass removes them.
/^\/\*proto\*/s/^\/\*proto\* *\(.*\)$/@findex \1\
@subsubsection @code{\1}/
#
# /*proto-internal* is just like /*proto* from doc point of view.
/^\/\*proto-internal\*/s/^\/\*proto-internal\* *\(.*\)$/@findex \1\
@subsubsection @code{\1}/
#
# *i at beginning of line: rest of line is both a subsubsection heading
# and an entry in function index.
/^\*i/s/^\*i *\(.*\)$/@findex \1\
@subsubsection @code{\1}/
#
# Two alternative docn block ends, '*/' and '*-*/' on lines by themselves;
# replace by blank lines (for texinfo source readability).
/^\*\/$/c\
/^\*-\*\/$/c\
# {* and *} are standins for comment markers (originally embedded in .c
# comments)---turn into real comment markers:
s/{\*/\/\*/
s/\*}/\*\//
#
# '*+++' and '*---' span a block of text that includes both example lines
# (marked by leading '$') and explanatory text (to be italicized).
# Italicize lines lacking '$':
/\*\+\+\+/,/\*---/s/^\([^$].*\)$/@i{\1}/
#
# We don't need *+++ and *--- markers any more; kill them (trailing marker
# becomes blank line for readability)
/\*\+\+\+/d
/\*---/c\
# Any line beginning with '$' is made an example line; third pass later
# coalesces adjacent example blocks. *DO NOT* introduce extra space after
# @end example, so we can spot adjacent ones in third pass.
/^\$/i\
@example
/^\$/a\
@end example
#
# In any example line, turn '{' and '}' into '@{' and '@}'
###/^\$/s/{/@{/g
###/^\$/s/}/@}/g
#
# Now delete the '$' markers themselves:
/^\$/s/\$//
#
# *+ and *- delimit large examples to be enclosed in cartouches.
/^\*\+$/c\
@lisp\
@cartouche
/^\*-$/c\
@end cartouche\
@end lisp\
# '*;' introduces an example which may have a single line or multiple lines;
# it extends until the next semicolon (which is also printed).
# One-line case: (do this first; else second line address for multi-line case
# will include random text til we happen to end a line in a doc comment with
# a semicolon)
/^\*;.*;$/{
s/^\*;/@example\
/
s/;$/;\
@end example\
/
}
# Multi-line case:
/^\*;/,/.*;$/{
s/^\*;/@example\
/
s/;$/;\
@end example\
/
}