Commit d2bd432
authored
sphinxdocs: add typedef directive for documenting user-defined types (#2300)
This adds support for documenting user-defined Starlark "types".
Starlark doesn't have
user-defined types as a first-class concept, but an equivalent can be
done by using
`struct` with lambdas and closures. On the documentation side, the
structure of these
objects can be shown by have a module-level struct with matching
attributes.
On the Sphinx side of things, this is simple to support (and the
functionality was largely
already there): it's just having a directive with other directives
within it (this
is the same way other languages handle it).
On the Starlark side of things, its a bit more complicated. Stardoc can
process a
module-level struct, but essentially returns a list of `(dotted_name,
object_proto)`,
and it will only include object types it recognizes (e.g. functions,
providers, rules, etc).
To work within this limitation, the proto-to-markdown converter special
cases the name
"TYPEDEF" to indicate a typedef. Everything with the same prefix is then
treated as
a member of the typedef and nested within the generated typedef
directive. Conveniently,
because the "TYPEDEF" object is a function, it can then include that in
the output
and we get "class doc" functionality for free.
This is mostly motivated by converting rules_testing to use sphinxdocs.
While rules_python
has a couple user-define types (e.g. the depset/runfiles/PyInfo
builders),
rules_testing has dozens of such types, which makes it untenable to
hand-write docs
describing them all. Today, rules_testing is already mostly following
the format sphinxdocs
proscribes to generate its at
https://rules-testing.readthedocs.io/en/latest/api/index.html,
and it's worked pretty well.1 parent ced0c10 commit d2bd432
File tree
8 files changed
+360
-20
lines changed- sphinxdocs
- docs
- private
- src/sphinx_bzl
- tests
- proto_to_markdown
- sphinx_stardoc
8 files changed
+360
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
230 | 235 | | |
231 | 236 | | |
232 | 237 | | |
| |||
237 | 242 | | |
238 | 243 | | |
239 | 244 | | |
240 | | - | |
| 245 | + | |
241 | 246 | | |
242 | 247 | | |
243 | 248 | | |
244 | 249 | | |
245 | 250 | | |
246 | | - | |
| 251 | + | |
247 | 252 | | |
248 | 253 | | |
249 | 254 | | |
250 | 255 | | |
251 | | - | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
252 | 259 | | |
253 | 260 | | |
254 | 261 | | |
255 | 262 | | |
256 | 263 | | |
257 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
99 | 108 | | |
100 | 109 | | |
101 | 110 | | |
| |||
115 | 124 | | |
116 | 125 | | |
117 | 126 | | |
118 | | - | |
119 | 127 | | |
120 | 128 | | |
121 | 129 | | |
122 | | - | |
| 130 | + | |
123 | 131 | | |
124 | 132 | | |
125 | 133 | | |
| |||
130 | 138 | | |
131 | 139 | | |
132 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
133 | 144 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
| 145 | + | |
| 146 | + | |
138 | 147 | | |
139 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
140 | 166 | | |
141 | 167 | | |
142 | 168 | | |
| |||
242 | 268 | | |
243 | 269 | | |
244 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
245 | 290 | | |
246 | | - | |
| 291 | + | |
247 | 292 | | |
248 | 293 | | |
249 | 294 | | |
250 | | - | |
| 295 | + | |
| 296 | + | |
251 | 297 | | |
252 | 298 | | |
253 | 299 | | |
| |||
268 | 314 | | |
269 | 315 | | |
270 | 316 | | |
271 | | - | |
| 317 | + | |
272 | 318 | | |
273 | 319 | | |
274 | | - | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
275 | 324 | | |
276 | 325 | | |
277 | 326 | | |
| |||
0 commit comments