-
Notifications
You must be signed in to change notification settings - Fork 541
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sphinxdocs: add docs; support sources from other directories
Documents how to use Sphinx syntax when writing docs. There's a variety of features the `sphinx_bzl` plugin enables, but without docs, they're somewhat hard to discover and figure out how to use. Because sphinxdocs is almost entirely separate, adding its docs under `//sphinxdocs/docs` is a more natural fit. Unfortunately, this became very verbose, repetitive, and tedious, for two reasons: 1. The only way `sphinx_docs` could accept files from other directories was using the `rename_srcs` arg and manually renaming files one-by-one. 2. Similarly, `sphinx_stardocs` required a one-by-one mapping of each bzl file to its output file, which then had to be repeated in `rename_srcs`. To fix (1), the `sphinx_docs.deps` attribute and `sphinx_docs_library` rule are added. The library targets collect files, and `sphinx_docs` moves then into the final Sphinx sources directory. To fix (2), the `sphinx_stardoc.srcs` attribute is added, which accepts `bzl_library` targets. I noticed that, in almost all cases, the output name was simply the input name with the `.md` extension, so the rule now does that by default. For special cases, the `sphinx_stardoc` (singular) rule can be called directly. Also: * Adds `bzl:rule` as a cross reference lookup role * Removes some defunct stuff relating to the stardoc template files that aren't used anymore. * Disables warnings from the autosectionlabel extension. These were spamming warnings because CHANGELOG.md has many headers with the same name. * Adds more entries to bazel inventory (all of native and ctx)
- Loading branch information
Showing
24 changed files
with
998 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
load("//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library") | ||
load("//sphinxdocs:sphinx_stardoc.bzl", "sphinx_stardocs") | ||
|
||
package(default_visibility = ["//:__subpackages__"]) | ||
|
||
sphinx_docs_library( | ||
name = "docs_lib", | ||
deps = [ | ||
":artisian_api_docs", | ||
":artisian_docs", | ||
":bzl_docs", | ||
], | ||
) | ||
|
||
sphinx_docs_library( | ||
name = "artisian_docs", | ||
srcs = glob( | ||
["**/*.md"], | ||
exclude = ["api/**"], | ||
), | ||
prefix = "sphinxdocs/", | ||
) | ||
|
||
sphinx_docs_library( | ||
name = "artisian_api_docs", | ||
srcs = glob( | ||
["api/**/*.md"], | ||
), | ||
) | ||
|
||
sphinx_stardocs( | ||
name = "bzl_docs", | ||
srcs = [ | ||
"//sphinxdocs:readthedocs_bzl", | ||
"//sphinxdocs:sphinx_bzl", | ||
"//sphinxdocs:sphinx_docs_library_bzl", | ||
"//sphinxdocs:sphinx_stardoc_bzl", | ||
"//sphinxdocs/private:sphinx_docs_library_bzl", | ||
], | ||
prefix = "api/", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
:::{bzl:currentfile} //sphinxdocs:BUILD.bazel | ||
::: | ||
|
||
# //sphinxdocs | ||
|
||
:::{bzl:flag} extra_defines | ||
Additional `-D` values to add to every Sphinx build. | ||
|
||
This is a list flag. Multiple uses are accumulated. | ||
|
||
This is most useful for overriding e.g. the version when performing | ||
release builds. | ||
::: | ||
|
||
:::{bzl:flag} extra_env | ||
Additional environment variables to for every Sphinx build. | ||
|
||
This is a list flag. Multiple uses are accumulated. Values are `key=value` | ||
format. | ||
::: | ||
|
||
:::{bzl:flag} quiet | ||
Whether to add the `-q` arg to Sphinx invocations. | ||
|
||
This is a boolean flag. | ||
|
||
This is useful for debugging invocations or developing extensions. The Sphinx | ||
`-q` flag causes sphinx to produce additional output on stdout. | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
:::{bzl:currentfile} //sphinxdocs/inventories:BUILD.bazel | ||
::: | ||
|
||
# //sphinxdocs/inventories | ||
|
||
:::{bzl:target} bazel_inventory | ||
A Sphinx inventory of Bazel objects. | ||
|
||
By including this target in your Sphinx build and enabling intersphinx, cross | ||
references to builtin Bazel objects can be written. | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Docgen using Sphinx with Bazel | ||
|
||
The `sphinxdocs` project allows using Bazel to run Sphinx to generate | ||
documentation. It comes with: | ||
|
||
* Rules for running Sphinx | ||
* Rules for generating documentation for Starlark code. | ||
* A Sphinx plugin for documenting Starlark and Bazel objects. | ||
* Rules for readthedocs build integration. | ||
|
||
While it is primarily oriented towards docgen for Starlark code, the core of it | ||
is agnostic as to what is being documented. | ||
|
||
|
||
```{toctree} | ||
:hidden: | ||
starlark-docgen | ||
sphinx-bzl | ||
``` |
Oops, something went wrong.