-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: implement Starlark domain plugin for Sphinx (#1909)
This implements a Sphinx plugin to support Starlark as a first-class domain in Sphinx. A Starlark domain allows writing object descriptions directly using Sphinx's object markup language, which allows better integration with cross references, understanding and distinguishing types, rendering information about things, and referencing types from other projects. Note that this doesn't affect the docs today because the proto_to_markdown tool is still generating regular markdown; updating that to generate Sphinx domain markdown will be done separately. Summary of features: * Types and arguments can be documented using Python syntax, e.g. `list[str]` This includes unions, generics, and custom types. Each component of the type expression is linked and cross referenced appropriately. Each object can have its approprate pieces documented and defined (e.g. a rule can have attributes, attributes can have their defaults etc documented, etc) * An index of Starlark objects is generated automatically. This makes it easy, for example, to find the rules that have a particular attribute. * The following objects can be documented: functions, methods, rules, repository rules, providers, aspects, bzlmod extensions, tag classes, targets, flags, and attributes/fields of the aforementioned objects. * Arbitary docs can cross reference to Starlark types. e.g., a manually written "Getting Started" doc can write `{bzl:obj}PyInfo.some_field` and it will automatically link to the appropriate API docs. * Resolution of cross-references is much smarter and customizable. Instead of relying Markdown's link resolution rules, the Sphinx's crossreference resolution hooks are used. This allows more concise references (e.g., just a rule's base name), distinguishing a particular object type (e.g. a function vs rule), or referring to an absolute object.
- Loading branch information
Showing
22 changed files
with
1,977 additions
and
11 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 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 |
---|---|---|
|
@@ -10,4 +10,5 @@ dependencies = [ | |
"sphinx_rtd_theme", | ||
"readthedocs-sphinx-ext", | ||
"absl-py", | ||
"typing-extensions" | ||
] |
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,14 @@ | ||
load("//python:py_library.bzl", "py_library") | ||
|
||
package( | ||
default_visibility = ["//:__subpackages__"], | ||
) | ||
|
||
# NOTE: This provides the library on its own, not its dependencies. | ||
py_library( | ||
name = "sphinx_stardoc", | ||
srcs = glob(["*.py"]), | ||
imports = [".."], | ||
# Allow depending on it in sphinx_binary targets | ||
visibility = ["//visibility:public"], | ||
) |
Empty file.
Oops, something went wrong.