manual: Parameterize \apidoc cmd with section type

This commit is contained in:
Stephen Sherratt 2017-05-24 13:43:27 +10:00
parent c7471db9b5
commit 58cbddecff
3 changed files with 28 additions and 9 deletions

View file

@ -66,6 +66,15 @@
\newcommand{\Htextbf}[1]{\textbf{\hyperpage{#1}}}
\urlstyle{rm}
% If statements
\usepackage{ifthen}
% Numbered subsubsections
\setcounter{secnumdepth}{5}
% Subsubsections it table of contents
\setcounter{tocdepth}{5}
% API functions / Kernel Objects
\newcommand{\obj}[1]{\textsf{\small #1}}
\newcommand{\apifunc}[2]{\hyperref[api:#2]{\texttt{#1()}}}

View file

@ -14,14 +14,19 @@
\newcommand{\inputapidoc}[1] {\input{parts/api/#1.tex}}
\newcommand{\inputgeneratedapidoc}[1] {\input{generated/#1.tex}}
\newcommand{\apidoc}[7]
\newcommand{\apidoc}[8][subsection]
{
\subsection{\label{api:#1}#2}
\ifthenelse{\equal{#1}{subsection}}{
\subsection{\label{api:#2}#3}
}{}
\ifthenelse{\equal{#1}{subsubsection}}{
\subsubsection{\label{api:#2}#3}
}{}
\texttt{#4}
\texttt{#5}
\vspace*{6pt}
#3
#4
\begin{center}
\begin{minipage}{0.95\textwidth}
@ -29,15 +34,15 @@
\toprule
\textbf{Type} & \textbf{Name} & \textbf{Description} \\
\midrule
#5
#6
\bottomrule
\end{tabularx}
\end{minipage}
\end{center}
\textit{Return value:} #6 \par
\textit{Return value:} #7 \par
\textit{Description:} #7 \par
\textit{Description:} #8 \par
\vfill
}

View file

@ -182,7 +182,7 @@ def build_ref_dict(doc):
# Takes a path to a file containing doxygen-generated xml,
# and return a string containing latex suitable for inclusion
# in the sel4 manual.
def generate_general_syscall_doc(input_file_name):
def generate_general_syscall_doc(input_file_name, level):
with open(input_file_name, "r") as f:
output = ""
doc = xml.dom.minidom.parse(f)
@ -192,6 +192,7 @@ def generate_general_syscall_doc(input_file_name):
details, params, ret = parse_detailed_desc(member, ref_dict)
output += """
\\apidoc
[{%(level)s}]
{%(label)s}
{%(name)s}
{%(brief)s}
@ -200,6 +201,7 @@ def generate_general_syscall_doc(input_file_name):
{%(ret)s}
{%(details)s}
""" % {
"level": level,
"label": manual_node.getAttribute("label"),
"name": latex_escape(manual_node.getAttribute("name")),
"brief": parse_brief(member),
@ -219,6 +221,9 @@ def process_args():
parser.add_argument("-o", "--output", dest="output", type=str,
help="Output latex file.")
parser.add_argument("-l", "--level", choices=["subsection", "subsubsection"],
help="LaTeX section level for each method")
return parser
def main():
@ -227,7 +232,7 @@ def main():
if not os.path.exists(os.path.dirname(args.output)):
os.makedirs(os.path.dirname(args.output))
output_str = generate_general_syscall_doc(args.input)
output_str = generate_general_syscall_doc(args.input, args.level)
with open(args.output, "w") as output_file:
output_file.write(output_str)