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

Build the reference manual incrementally #6495

Closed
qed777 mannequin opened this issue Jul 9, 2009 · 322 comments
Closed

Build the reference manual incrementally #6495

qed777 mannequin opened this issue Jul 9, 2009 · 322 comments

Comments

@qed777
Copy link
Mannequin

qed777 mannequin commented Jul 9, 2009

Building the Sage reference manual can take a significant amount of time. Decreasing this time could speed up Sage development.

The patch is large, but most of it consists of moving files from one location to another, as described below. A summary of the changes:

Changes in doc/en/reference — this is where the size of the patch comes from, although the changes are pretty simple:

  • rearrange the directory doc/en/reference: for each file like algebras.rst, create a subdirectory algebras and move algebras.rst to algebras/index.rst. Also create a file algebras/conf.py for the build configuration. All of these new conf.py files are identical. Deal with the contents of the directory reference/media similarly, moving the pictures to the appropriate subdirectory.
  • modify reference/index.rst to point to these new files.
  • reorganize reference/index.rst so it is arranged, at least somewhat, by topic.
  • add intersphinx to conf.py — see below. Also add the new subdirectories to the list exclude_trees.
  • new file conf_sub.py, configuration for the pieces of the documentation (as opposed to the main conf.py, which is for building reference/index.rst). This file is imported by each of the files SUBDIRECTORY/conf.py.

Changes to doc/common/builder.py:

  • add code to build the reference manual in sections, and also to build the sections in parallel. The reference manual ought to be built twice to resolve references now, so typing "sage -docbuild all html" will build it twice (along with all of the other documents, of course). "sage -docbuild reference html" will just build it once. You can also run "sage -docbuild reference/combinat html", for example, to just build one part of the manual.
  • the different parts of the manual are separate documents as far as sphinx is concerned, so allow them to reference each other using the "intersphinx" extension. (This is why we need to build it twice: the first pass assembles the intersphinx databases, the second pass uses the databases to create the references correctly.)
  • to accomodate the changes in Add todo extension to Sphinx #11251, which don't seem to be easily compatible with intersphinx, search through the output files looking for "todo" items, and accumulate them in one master "todo" list.
  • for pdf format, since it now produces 30 different pdf files, write an html file which links to each of them.

Other changes:

  • doc/common/conf.py: add the intersphinx extension to the build process.
  • doc/common/themes/sage/layout.html: fix a bug where clicking the Sage logo in the upper left corner of the docs wouldn't take you to the right place, at least in the local documentation.
  • doc/common/themes/sageref/: add a new theme for the pieces of the reference manual. This is almost identical to the "sage" theme, except for a little tinkering to the links along the top and bottom lines.
  • in the main Sage library, change a few pathnames to media files in the reference manual, since those files have been moved.
  • make the necessary changes to .hgignore and MANIFEST.in to deal with the relocated files.

The html docs for Sage 5.4.rc2,
html without MathJax,
html with MathJax, and
pdf,
built after applying the patches here.


Apply:


Before building the docs, you should delete the documentation output directory: rm -rf SAGE_ROOT/devel/sage/doc/output. To test this, you should run sage --docbuild all html and sage --docbuild all pdf. (Note: just running sage --docbuild reference html will probably produce many warnings. If you run it a second time, the warnings should go away.)

Depends on #13064
Depends on #8327
Depends on #13891

Dependencies: 5.7.beta2 + #13064, #8327, #13891

CC: @jhpalmieri @nexttime @nilesjohnson @hivert @mguaypaq @mwhansen

Component: documentation

Keywords: days38

Author: Mitesh Patel, John Palmieri, Florent Hivert

Reviewer: Volker Braun, Florent Hivert

Merged: sage-5.8.beta0

Issue created by migration from https://trac.sagemath.org/ticket/6495

@qed777 qed777 mannequin added c: documentation labels Jul 9, 2009
@qed777
Copy link
Mannequin Author

qed777 mannequin commented Jul 9, 2009

Experimental.

@qed777
Copy link
Mannequin Author

qed777 mannequin commented Jul 9, 2009

Author: Mitesh Patel

@qed777
Copy link
Mannequin Author

qed777 mannequin commented Jul 9, 2009

comment:1

Attachment: trac_6495_ref_pdf_pieces.patch.gz

The attached patch is experimental. Notes:

  • sage -docbuild reference pdf fails to build arithgroup.pdf, apparently because of the math macro \ZZ in the title. Unfortunately, I don't know how to fix this.
  • Since it replaces the top level PDF file with several smaller files, it breaks the patch at add link to PDF manuals in doc/html/index.html #4460.
  • It's not clear what happens to cross-ReST document links. I'll try to investigate.

@qed777
Copy link
Mannequin Author

qed777 mannequin commented Sep 11, 2009

comment:2

On cross-PDF document links: It seems that Sphinx does not produce these. This may OK, since file:// URLs can break easily.

@qed777
Copy link
Mannequin Author

qed777 mannequin commented Sep 11, 2009

comment:3

On the \ZZ in arithgroup.tex: It seems the problem stems from \@title in

    \ifsphinxpdfoutput
      \begingroup
      % This \def is required to deal with multi-line authors; it               
      % changes \\ to ', ' (comma-space), making it pass muster for             
      % generating document info in the PDF file.                               
      \def\\{, }
      \pdfinfo{
        /Author (\@author)
        /Title (\@title)
      }
      \endgroup
    \fi

in Sphinx's manual.cls. For some reason, the \math* font commands do not work in this context. I gather that \mathbf is preferred, but one workaround is to use

Arithmetic Subgroups of `{\rm SL}_2({\bf Z})`

in place of

Arithmetic Subgroups of `{\rm SL}_2(\ZZ)`

in arithgroup.rst.

@qed777
Copy link
Mannequin Author

qed777 mannequin commented Nov 29, 2009

Attachment: trac_6495-reference_breakup.patch.gz

Another approach. Depends on #7549. Still experimental. This patch only. sage repo.

@qed777
Copy link
Mannequin Author

qed777 mannequin commented Nov 29, 2009

comment:4

The new patch may make it possible to build and update reference manual chapters semi-independently. I think we can use the intersphinx extension to fix the cross-chapter references. But we'll need to build the manual twice, a la LaTeX.

To build just a chapter, try, e.g.,

sage -docbuild reference/algebras html -juiv3

Still to do:

  • Make a combined index page and search page.
  • Check that PDF generation works.
  • Combine chapter PDF files into one large [optional] PDF file (with pdfjam's pdfjoin)?
  • Use a specific LaTeX doc title in each conf.py.
  • Fix the "Arithmetic Subgroups" heading on the top-level page.
  • Use a visual, 2D layout for the top-level page? Group by general area? Add icons?
  • Get a reply from sphinx-dev about making relative paths work.
  • Build docs in parallel (cf. update doc system to jsmath and improve build system (parallel doc builds) #6255) with multiprocessing?
  • Replace the "website" PDF link?
  • User-friendliness improvements.
  • Encourage more compact chapters? It seems that "Combinatorics" takes the most time and memory.
  • ...

@qed777 qed777 mannequin changed the title Break up the PDF reference manual into smaller pieces Build the reference manual incrementally Nov 29, 2009
@qed777 qed777 mannequin added p: major / 3 and removed p: minor / 4 labels Nov 29, 2009
@qed777
Copy link
Mannequin Author

qed777 mannequin commented Nov 29, 2009

comment:5

Another important item:

  • Use just one _static directory for the manual, not 50+!

@qed777
Copy link
Mannequin Author

qed777 mannequin commented Nov 29, 2009

comment:6

If this approach is viable, I suggest leaving many (most?) of the "To Do" items for other tickets.

@qed777
Copy link
Mannequin Author

qed777 mannequin commented Nov 29, 2009

comment:7

While I'm here:

  • Copy PDFs from output/latex/ to output/pdf, so that make all-pdf, at least, doesn't do unnecessary work?

@qed777

This comment has been minimized.

@qed777
Copy link
Mannequin Author

qed777 mannequin commented Dec 3, 2009

PDF fixes. This patch only. sage repo.

@qed777
Copy link
Mannequin Author

qed777 mannequin commented Dec 3, 2009

comment:9

Attachment: trac_6495-reference_breakup_v2.patch.gz

Sphinx caches "foreign" object inventories in a document's environment.pickle. These now use a lot of disk space.

@qed777
Copy link
Mannequin Author

qed777 mannequin commented Dec 6, 2009

comment:10

Replying to @qed777:

Sphinx caches "foreign" object inventories in a document's environment.pickle. These now use a lot of disk space.

Another sphinx-dev query.

@jhpalmieri
Copy link
Member

comment:12

Here's a new patch, rebased to Sage 4.7.1.alpha4. This implements parallel building, and it provides a great speedup, at least on systems with lots of processors. For example, on sage.math, the time to execute sage -docbuild reference html -j went from about 18 minutes to just under 2 minutes. The main idea is to build each module of the reference manual separately, and use the Sphinx intersphinx extension to handle cross-references (so :class:`blah` will work in the algebras module, even if blah is defined in the rings module).

Remaining issues:

  • The new build uses up more disk space than the old, by about 120 megabytes. I don't know if anything can be done about this, and I also don't think it's a big deal. (With the previous patch, it took about 1 gigabyte more, but the more recent patch manages to cut that down: in the previous patch, the _static subdirectory of the documentation was being copied, once for each module of the reference manual, and with the new version, a symlink is used instead.)
  • There are now some missing bibliographic references: at some point in the past, people have gone through the documentation and unified the references, but this means that references in one module are not seen by any other. This can be fixed just by copying the references to the module where they're used. For example: CMR05 is referenced somewhere in the module on polynomial rings, but the actual item is described in crypto/mq/sr.py.
  • The cross-referencing in intersphinx is not perfect; in particular, it doesn't seem to work after building the documents once, it needs to have the full doctree "inventory" for any module available before resolving references to that module. Since the inventory files are built alongside the documentation, this means it has to be built twice (as far as I can tell) before cross-all of the references work. We could try to figure out dependencies and make sure that if module A is referenced in module B, then A is built first, but that seems complicated, and there is no reason for there not to be circular references. I'm tempted to just allow broken cross-references. For the docs on the web site, we would have to make sure they got built twice.
  • There is a main index for the reference manual, but once you click on any entry (like "Cryptography"), you get to that module's index, and there is no link taking you back to the main index. There ought to be a way to fix this, but I haven't figured it out yet.

@vbraun
Copy link
Member

vbraun commented Jul 7, 2011

comment:13

In an ideal world sphinx would be multithreaded, but we probably shouldn't wait for that ;-) The remaining issues about disk space, bibliographic references, and needing two runs seem to be unavoidable. Building parallel gets more and more important, so I think the benefits outweigh the disadvantages.

I tried the patch on Sage-4.7.1.alpha4 without any other patches applied:

  • Only the main page has proper css. For example, html/en/reference/cmd/index.html refers to _static/sage.css but the correct path would be ../_static/sage.css.
  • patch conflicts with Add todo extension to Sphinx #11251 (todo extension). Given that the latter is already positively reviewed, maybe this ticket could be rebased on top of it?
  • During the sage build, I think we should then run the docbuilder twice for the reference manual. Perhaps this should always be done for sage -docbuild all.
  • Can we make output less verbose? The whole intersphinx output scrolled forever off my screen. Ideally, an interspinx failure to find an inventory file would only add one extra line at the end of the build along the lines of "You should re-run docbuild to get references right."

@vbraun
Copy link
Member

vbraun commented Jul 7, 2011

Reviewer: Volker Braun

@vbraun vbraun added this to the sage-4.7.2 milestone Jul 7, 2011
@jhpalmieri
Copy link
Member

Changed author from Mitesh Patel to Mitesh Patel, John Palmieri

@jhpalmieri
Copy link
Member

Dependencies: 11251

@jhpalmieri
Copy link
Member

comment:14

Replying to @vbraun:

I tried the patch on Sage-4.7.1.alpha4 without any other patches applied:

  • Only the main page has proper css. For example, html/en/reference/cmd/index.html refers to _static/sage.css but the correct path would be ../_static/sage.css.

This was a mistake in the previous version: it was supposed to create a link from reference/_static to reference/cmd/_static. Now it should work.

  • patch conflicts with Add todo extension to Sphinx #11251 (todo extension). Given that the latter is already positively reviewed, maybe this ticket could be rebased on top of it?

Good point. This raises another problem: intersphinx doesn't easily pass todo lists between different documents, so I don't know how to get a master todo list for the Sage library. Right now, I've put the todolist for each module after its table of contents. I think combinat is the only module with any actual to do elements.

  • During the sage build, I think we should then run the docbuilder twice for the reference manual. Perhaps this should always be done for sage -docbuild all.

Done: sage -docbuild all now builds the reference manual twice. I also added a few print statements to the docbuild process.

  • Can we make output less verbose? The whole intersphinx output scrolled forever off my screen. Ideally, an interspinx failure to find an inventory file would only add one extra line at the end of the build along the lines of "You should re-run docbuild to get references right."

I've tried to do this when doing sage -docbuild all and not in general, but it may be suppressing too much output. (In the first pass, all warnings are suppressed, including intersphinx warnings, and in the second pass, any warnings should be printed. But in the second pass, it's just rewriting output, taking intersphinx links into account -- it's not reading the sources a second time, so it doesn't produce warnings about missing bibliographic references.)

Other issues:

  • In PDF output, this produces one PDF file for each module, but there is no "master" file linking to them. I hope we can create one. Should it be an html file or a PDF file?

  • We could perhaps speed things up more by breaking the combinat module, which is by far the largest, into several pieces. This can happen on another ticket.

  • I've reorganized the main index for the reference manual, grouping modules together by topic. I hope it's easier to find things this way. I wonder if we can get intersphinx to produce a master index for all of the documents...

  • in the old version, at least on my computer, when I clicked on the Sage logo in the top left corner, it wasn't taking me to the right place. I've fixed that. Along the same lines, with the new reorganization, the other links on the top line look a little funny to me in the reference manual. They looked worse before and I've tried to clean them up, but maybe they could use more work?

@vbraun
Copy link
Member

vbraun commented Feb 15, 2013

comment:258

I've replaced the bare except:.

@jdemeyer
Copy link

Merged: sage-5.8.beta0

@hivert
Copy link

hivert commented Feb 17, 2013

comment:260

Hurrah !!!

@anneschilling
Copy link

comment:261

Could I make one suggestion (perhaps for a later ticket)? Compiling the docs does not say any longer where to look on one's machine for the compiled docs. This was a very useful feature beforehand!

Thanks for your work on this!

Anne

@jhpalmieri
Copy link
Member

comment:262

Replying to @anneschilling:

Could I make one suggestion (perhaps for a later ticket)? Compiling the docs does not say any longer where to look on one's machine for the compiled docs. This was a very useful feature beforehand!

See #14148.

@jdemeyer
Copy link

comment:263

See #14156 for a blocker follow-up.

@jdemeyer
Copy link

comment:264

See #14199 for another follow-up.

@jdemeyer
Copy link

jdemeyer commented Mar 6, 2013

comment:265

Can somebody here please review blocker ticket #14199?

@hivert
Copy link

hivert commented Mar 8, 2013

comment:266

Another followup #14245: cloning is broken.

@jdemeyer
Copy link

comment:267

Followup #14626: docbuilder hangs if latex fails.

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

No branches or pull requests