[meta] Make writing and reading our in-tree documentation a first class experience
Categories
(Developer Infrastructure :: Source Documentation, enhancement)
Tracking
(Not tracked)
People
(Reporter: ahal, Unassigned)
References
(Depends on 11 open bugs)
Details
(Keywords: meta)
Despite being critically important, our in-tree documentation system is neglected, without owner and without direction. Writing documentation can be painful, and reading the output of the documentation is even more painful:
https://firefox-source-docs.mozilla.org/
This bug is going to track all the issues we need to fix to improve the status quo. It will also act as the launching point for a GSoC proposal I've submitted (which is my main motivation for filing this meta bug).
Updated•5 years ago
|
Reporter | ||
Comment 1•5 years ago
•
|
||
This comment is a description of how the doc system works with some links to code. This is a very general overview that is intended to provide context for anyone working on any of the dependencies filed against this meta bug.
Registration
The goal of our doc system is to allow individual teams and developers the ability to create and maintain their own domain specific documentation. We don't want to act as gatekeepers. In order for this to work, we need some mechanism for developers to register a doc dir.
Documentation gets registered by developers via moz.build
files. For example:
https://searchfox.org/mozilla-central/rev/4763b8d576ce52625d245d1ab6d9404ea025b026/tools/moz.build#53
There are two variables, SPHINX_TREES
and SPHINX_PYTHON_PACKAGE_DIRS
and some information on them can be found here:
https://searchfox.org/mozilla-central/rev/4763b8d576ce52625d245d1ab6d9404ea025b026/python/mozbuild/mozbuild/frontend/context.py#2004
Generation
Documentation is generated using sphinx with some custom tooling to hook in all of the directories that are registered via moz.build
. Aside from sphinx itself, there are 3 pieces to this stage:
-
mach command
This is the command line entry point for generating and uploading docs. It is mostly just a thin wrapper aroundsphinx-build
, but also acts like the glue that holds the system together. -
custom sphinx extension
A custom sphinx extension that acts as a hook from which we can run all our customized operations before the regular 'sphinx-build' kicks in. This module is registered in the main conf.py. This extension adds a couple custom sphinx directives as well, but otherwise isn't very interesting. -
moztreedocs
A little python module containing the meat of the custom generation code. It is invoked fromsphinx.py
above and is responsible for reading themoz.build
variables and copying all of the relevant source files into a staging directory in the objdir. Once all the source files have been copied,sphinx-build
will run against the staging dir.
At a high level, the doc generation process will go something like this:
- User runs
mach doc
ormach doc <subdir>
- Mach command runs
sphinx-build
withtools/docs/conf.py
as the config file. - The
mozbuild.sphinx
extension is registered in this config file. - This extension has a setup hook which calls into
moztreedocs
. moztreedocs
reads all themoz.build
sphinx variables and copies all the source files to a staging dir.- The
mozbuild.sphinx
extension getssphinx-build
to build the docs from this staging directory. sphinx-build
resumes as normal, typically a directory next to the staging dir will contain the html output.
Publication
Publishing docs is a separate step from generation, but uses the same mach command: mach doc --upload
. This step is much simpler than the generation one. The docs are hosted on a static Amazon S3 bucket behind this domain:
https://firefox-source-docs.mozilla.org/
The mach doc --upload
command uses Amazon's boto3
library to push the output dir generated in step 7 above up to the static server:
https://searchfox.org/mozilla-central/source/tools/docs/moztreedocs/upload.py
And that's it.
Continuous Integration
While it is possible to generate docs locally, publishing requires special credentials. Generation and publication are handled by two separate tasks (Doc
and DocUp
respectively). They are defined here:
https://searchfox.org/mozilla-central/source/taskcluster/ci/source-test/doc.yml
These tasks will run whenever someone modifies a doc source file, so changes to the documentation should be automatically picked up and published once the patch lands to mozilla-central. While it's nice to have this automated system, we do still care about running mach doc
locally as developers will typically want to see how their modifications look before pushing.
Reporter | ||
Updated•5 years ago
|
Updated•5 years ago
|
(In reply to Andrew Halberstadt [:ahal] from comment #0)
HI @Andrew Halberstadt,
I'm a newcomer. I read description of this bug but I don't know how to start.
May you help me with some simple guidelines?
Thank you
Doan
Comment 3•3 years ago
|
||
I'm a newcomer. I read description of this bug but I don't know how to start.
Description of the bug explain the architecture of our docs infra and how it runs.
May you help me with some simple guidelines?
After setting up Firefox Docs locally, you can look into the bugs on which this meta bug is depended. If you have some questions feel free to ask in #firefox-source-docs in chat.mozilla.org
Updated•2 years ago
|
Updated•2 years ago
|
Updated•1 year ago
|
Updated•3 months ago
|
Description
•