mpi-forum / pympistandard

Other
4 stars 0 forks source link

Store section information for each routine / constant #11

Open zerothi opened 1 year ago

zerothi commented 1 year ago

In this way it will become very easy for MPI implementors to always have up to date references in their documentation.

martinruefenacht commented 1 year ago

Do you mean the actual numbered section, e.g. MPI_Send number "3.2.1" or just text "Blocking Send" which is a subsection?

The numbers are internal to Latex so I wouldn't have an idea to extract that.

zerothi commented 1 year ago

As far as I understood all these things were extracted from the tex files? And the writing the section (numbers and /or titles) isn't that much of a problem.

martinruefenacht commented 1 year ago

Yes the prepass has full access to all tex files, but at that time the numbers aren't determined yet, they are compile time latex internal. The names are easy. And the subsection/section labels are also easy of course.

I am not aware of a method with which I could extract the numbering at compile time, if there is then I could write this additionally into the json file of course.

zerothi commented 1 year ago

But upon a 2nd pass you'll also have access to the section numbers? This is just like the TOC which gets written.

Here is a small example:

\documentclass{article}
\usepackage{etoolbox}

\newwrite\outsections
\immediate\openout\outsections=\jobname.sectionnumbers

\def\concatvalue#1#2{%
    \ifnumequal{\value{#2}}{0}%
    % == 0
    {}% do nothing since #1 is already correct
    {\expandafter\edef\csname #1\endcsname{\csname #1\endcsname.\the\value{#2}}}
}

\makeatletter
\def\writecurrentsection{%
    \def\outcurrent@section{}%
    % \concatvalue{outcurrent@section}{chapter}%
    \concatvalue{outcurrent@section}{section}%
    \concatvalue{outcurrent@section}{subsection}%
    \concatvalue{outcurrent@section}{subsubsection}%
    \outcurrent@section%
    \expandafter\write\expandafter\outsections\expandafter{\outcurrent@section}%
}
\makeatother

\begin{document}

\writecurrentsection

\section{First}
\writecurrentsection

\section{Second}
\writecurrentsection
\subsection{Second Second}
\writecurrentsection
\end{document}

it will create the jobname.sectionnumbers with the numbers existing, of course it needs some editing, but in principle... I thought \thesection should work, but my 5 min of testing didn't figure out what I did wrong ;)

wgropp commented 1 year ago

Lots of things can't be determined (at least globally) until at least one pass has completed, and page numbers can require two passes (you get close on the first pass, but references to items, such as section numbers and page numbers, that are determined in the first pass, may change pagination on the second pass, needing a third pass for things to stabilize. There is quite a bit of processing after the first pass for the bib and index entries, for example. And updating the index macros might be the easiest way to capture this information.

zerothi commented 1 year ago

Agreed that the n passes is necessary. I am just thinking about automating documentation utilities, and since the TeX files are the truth I think this small additional output is a small cost with a potential big gain :)

martinruefenacht commented 1 year ago

I guess we would just build a post-pass into the build system? We don't need intermediate data, but just what ever comes out after the pdf is fully built. But I need to read into the snippet you posted above. I am not enough into latex for that. :)

pre-pass, render, latex, post-pass

martinruefenacht commented 1 year ago

This actually also forces me to have a look at the binding_prepass and binding_emitter code which is probably a good thing. It is not as modular as it could be. I discovered that in the constants branch where I had to copy paste the entire parse_file function.