@@ -97,7 +97,7 @@ def write_docs(
97
97
attribute. For some classes (list, tuple, etc) __doc__ is not writable.
98
98
Pass those docs like: `extra_docs={id(obj): "docs"}`
99
99
page_builder_classes: A optional dict of `{ObjectType:Type[PageInfo]}` for
100
- overriding the default page builder classes.
100
+ overriding the default page builder classes.
101
101
102
102
Raises:
103
103
ValueError: if `output_dir` is not an absolute path
@@ -168,12 +168,13 @@ def write_docs(
168
168
if api_report is not None :
169
169
api_report .write (output_dir / root_module_name / 'api_report.pb' )
170
170
171
-
172
171
if num_docs_output <= 1 :
173
- raise ValueError ('The `DocGenerator` failed to generate any docs. Verify '
174
- 'your arguments (`base_dir` and `callbacks`). '
175
- 'Everything you want documented should be within '
176
- '`base_dir`.' )
172
+ raise ValueError (
173
+ 'The `DocGenerator` failed to generate any docs. Verify '
174
+ 'your arguments (`base_dir` and `callbacks`). '
175
+ 'Everything you want documented should be within '
176
+ '`base_dir`.'
177
+ )
177
178
178
179
if yaml_toc :
179
180
if isinstance (yaml_toc , bool ):
@@ -286,15 +287,18 @@ class DocGenerator:
286
287
287
288
def __init__ (
288
289
self ,
290
+ * ,
289
291
root_title : str ,
290
292
py_modules : Sequence [Tuple [str , Any ]],
291
293
base_dir : Optional [Sequence [Union [str , pathlib .Path ]]] = None ,
292
294
code_url_prefix : Union [Optional [str ], Sequence [Optional [str ]]] = (),
295
+ self_link_base : Optional [str ] = None ,
293
296
search_hints : bool = True ,
294
297
site_path : str = 'api_docs/python' ,
295
298
private_map : Optional [Dict [str , str ]] = None ,
296
299
visitor_cls : Type [doc_generator_visitor .DocGeneratorVisitor ] = (
297
- doc_generator_visitor .DocGeneratorVisitor ),
300
+ doc_generator_visitor .DocGeneratorVisitor
301
+ ),
298
302
api_cache : bool = True ,
299
303
callbacks : Optional [List [public_api .ApiFilter ]] = None ,
300
304
yaml_toc : Union [bool , Type [toc_lib .TocBuilder ]] = True ,
@@ -315,12 +319,15 @@ def __init__(
315
319
in" paths. These are zipped with `base-dir`, to set the `defined_in`
316
320
path for each file. The defined in link for `{base_dir}/path/to/file` is
317
321
set to `{code_url_prefix}/path/to/file`.
322
+ self_link_base: A string. A URL prefix pre-pend to self-links to the
323
+ generated docs pages. Optional, if no `self_link_base` is supplied, no
324
+ self-link will be added.
318
325
search_hints: Bool. Include metadata search hints at the top of each file.
319
326
site_path: Path prefix in the "_toc.yaml"
320
327
private_map: DEPRECATED. Use `api_generator.doc_controls`, or pass a
321
- filter to the `callbacks` argument. A
322
- `{"module.path.to.object": ["names"]}` dictionary. Specific
323
- aliases that should not be shown in the resulting docs.
328
+ filter to the `callbacks` argument. A `{"module.path.to.object":
329
+ ["names"]}` dictionary. Specific aliases that should not be shown in the
330
+ resulting docs.
324
331
visitor_cls: An option to override the default visitor class
325
332
`doc_generator_visitor.DocGeneratorVisitor`.
326
333
api_cache: Bool. Generate an api_cache file. This is used to easily add
@@ -364,10 +371,13 @@ def __init__(
364
371
raise ValueError ('`code_url_prefix` cannot be empty' )
365
372
366
373
if len (self ._code_url_prefix ) != len (base_dir ):
367
- raise ValueError ('The `base_dir` list should have the same number of '
368
- 'elements as the `code_url_prefix` list (they get '
369
- 'zipped together).' )
374
+ raise ValueError (
375
+ 'The `base_dir` list should have the same number of '
376
+ 'elements as the `code_url_prefix` list (they get '
377
+ 'zipped together).'
378
+ )
370
379
380
+ self ._self_link_base = self_link_base
371
381
self ._search_hints = search_hints
372
382
self ._site_path = site_path
373
383
self ._private_map = private_map or {}
@@ -399,7 +409,9 @@ def make_parser_config(self,
399
409
path_tree = visitor .path_tree ,
400
410
api_tree = visitor .api_tree ,
401
411
base_dir = self ._base_dir ,
402
- code_url_prefix = self ._code_url_prefix )
412
+ code_url_prefix = self ._code_url_prefix ,
413
+ self_link_base = self ._self_link_base ,
414
+ )
403
415
404
416
def run_extraction (self ):
405
417
"""Walks the module contents, returns an index of all visited objects.
0 commit comments