Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store section information for each routine / constant #11

Open
zerothi opened this issue Feb 9, 2023 · 8 comments
Open

Store section information for each routine / constant #11

zerothi opened this issue Feb 9, 2023 · 8 comments

Comments

@zerothi
Copy link

zerothi commented Feb 9, 2023

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

@martinruefenacht
Copy link
Contributor

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
Copy link
Author

zerothi commented Feb 10, 2023

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
Copy link
Contributor

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
Copy link
Author

zerothi commented Feb 10, 2023

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
Copy link

wgropp commented Feb 10, 2023

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
Copy link
Author

zerothi commented Feb 10, 2023

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
Copy link
Contributor

martinruefenacht commented Feb 10, 2023

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants