1*60517a1eSAndroid Build Coastguard Worker# rules_python Sphinx docs generation 2*60517a1eSAndroid Build Coastguard Worker 3*60517a1eSAndroid Build Coastguard WorkerThe docs for rules_python are generated using a combination of Sphinx, Bazel, 4*60517a1eSAndroid Build Coastguard Workerand Readthedocs.org. The Markdown files in source control are unlikely to render 5*60517a1eSAndroid Build Coastguard Workerproperly without the Sphinx processing step because they rely on Sphinx and 6*60517a1eSAndroid Build Coastguard WorkerMyST-specific Markdown functionality. 7*60517a1eSAndroid Build Coastguard Worker 8*60517a1eSAndroid Build Coastguard WorkerThe actual sources that Sphinx consumes are in this directory, with Stardoc 9*60517a1eSAndroid Build Coastguard Workergenerating additional sources or Sphinx. 10*60517a1eSAndroid Build Coastguard Worker 11*60517a1eSAndroid Build Coastguard WorkerManually building the docs isn't necessary -- readthedocs.org will 12*60517a1eSAndroid Build Coastguard Workerautomatically build and deploy them when commits are pushed to the repo. 13*60517a1eSAndroid Build Coastguard Worker 14*60517a1eSAndroid Build Coastguard Worker## Generating docs for development 15*60517a1eSAndroid Build Coastguard Worker 16*60517a1eSAndroid Build Coastguard WorkerGenerating docs for development is a two-part process: starting a local HTTP 17*60517a1eSAndroid Build Coastguard Workerserver to serve the generated HTML, and re-generating the HTML when sources 18*60517a1eSAndroid Build Coastguard Workerchange. The quick start is: 19*60517a1eSAndroid Build Coastguard Worker 20*60517a1eSAndroid Build Coastguard Worker``` 21*60517a1eSAndroid Build Coastguard Workerbazel run //docs:docs.serve # Run in separate terminal 22*60517a1eSAndroid Build Coastguard Workeribazel build //docs:docs # Automatically rebuilds docs 23*60517a1eSAndroid Build Coastguard Worker``` 24*60517a1eSAndroid Build Coastguard Worker 25*60517a1eSAndroid Build Coastguard WorkerThis will build the docs and start a local webserver at http://localhost:8000 26*60517a1eSAndroid Build Coastguard Workerwhere you can view the output. As you edit files, ibazel will detect the file 27*60517a1eSAndroid Build Coastguard Workerchanges and re-run the build process, and you can simply refresh your browser to 28*60517a1eSAndroid Build Coastguard Workersee the changes. Using ibazel is not required; you can manually run the 29*60517a1eSAndroid Build Coastguard Workerequivalent bazel command if desired. 30*60517a1eSAndroid Build Coastguard Worker 31*60517a1eSAndroid Build Coastguard Worker### Installing ibazel 32*60517a1eSAndroid Build Coastguard Worker 33*60517a1eSAndroid Build Coastguard WorkerThe `ibazel` tool can be used to automatically rebuild the docs as you 34*60517a1eSAndroid Build Coastguard Workerdevelopment them. See the [ibazel docs](https://github.com/bazelbuild/bazel-watcher) for 35*60517a1eSAndroid Build Coastguard Workerhow to install it. The quick start for linux is: 36*60517a1eSAndroid Build Coastguard Worker 37*60517a1eSAndroid Build Coastguard Worker``` 38*60517a1eSAndroid Build Coastguard Workersudo apt install npm 39*60517a1eSAndroid Build Coastguard Workersudo npm install -g @bazel/ibazel 40*60517a1eSAndroid Build Coastguard Worker``` 41*60517a1eSAndroid Build Coastguard Worker 42*60517a1eSAndroid Build Coastguard Worker## MyST Markdown flavor 43*60517a1eSAndroid Build Coastguard Worker 44*60517a1eSAndroid Build Coastguard WorkerSphinx is configured to parse Markdown files using MyST, which is a more 45*60517a1eSAndroid Build Coastguard Workeradvanced flavor of Markdown that supports most features of restructured text and 46*60517a1eSAndroid Build Coastguard Workerintegrates with Sphinx functionality such as automatic cross references, 47*60517a1eSAndroid Build Coastguard Workercreating indexes, and using concise markup to generate rich documentation. 48*60517a1eSAndroid Build Coastguard Worker 49*60517a1eSAndroid Build Coastguard WorkerMyST features and behaviors are controlled by the Sphinx configuration file, 50*60517a1eSAndroid Build Coastguard Worker`docs/conf.py`. For more info, see https://myst-parser.readthedocs.io. 51*60517a1eSAndroid Build Coastguard Worker 52*60517a1eSAndroid Build Coastguard Worker## Sphinx configuration 53*60517a1eSAndroid Build Coastguard Worker 54*60517a1eSAndroid Build Coastguard WorkerThe Sphinx-specific configuration files and input doc files live in 55*60517a1eSAndroid Build Coastguard Workerdocs/. 56*60517a1eSAndroid Build Coastguard Worker 57*60517a1eSAndroid Build Coastguard WorkerThe Sphinx configuration is `docs/conf.py`. See 58*60517a1eSAndroid Build Coastguard Workerhttps://www.sphinx-doc.org/ for details about the configuration file. 59*60517a1eSAndroid Build Coastguard Worker 60*60517a1eSAndroid Build Coastguard Worker## Readthedocs configuration 61*60517a1eSAndroid Build Coastguard Worker 62*60517a1eSAndroid Build Coastguard WorkerThere's two basic parts to the readthedocs configuration: 63*60517a1eSAndroid Build Coastguard Worker 64*60517a1eSAndroid Build Coastguard Worker* `.readthedocs.yaml`: This configuration file controls most settings, such as 65*60517a1eSAndroid Build Coastguard Worker the OS version used to build, Python version, dependencies, what Bazel 66*60517a1eSAndroid Build Coastguard Worker commands to run, etc. 67*60517a1eSAndroid Build Coastguard Worker* https://readthedocs.org/projects/rules-python: This is the project 68*60517a1eSAndroid Build Coastguard Worker administration page. While most settings come from the config file, this 69*60517a1eSAndroid Build Coastguard Worker controls additional settings such as permissions, what versions are 70*60517a1eSAndroid Build Coastguard Worker published, when to publish changes, etc. 71*60517a1eSAndroid Build Coastguard Worker 72*60517a1eSAndroid Build Coastguard WorkerFor more readthedocs configuration details, see docs.readthedocs.io. 73