@@ -97,7 +97,7 @@ def write_docs(
9797 attribute. For some classes (list, tuple, etc) __doc__ is not writable.
9898 Pass those docs like: `extra_docs={id(obj): "docs"}`
9999 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.
101101
102102 Raises:
103103 ValueError: if `output_dir` is not an absolute path
@@ -168,12 +168,13 @@ def write_docs(
168168 if api_report is not None :
169169 api_report .write (output_dir / root_module_name / 'api_report.pb' )
170170
171-
172171 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+ )
177178
178179 if yaml_toc :
179180 if isinstance (yaml_toc , bool ):
@@ -286,15 +287,18 @@ class DocGenerator:
286287
287288 def __init__ (
288289 self ,
290+ * ,
289291 root_title : str ,
290292 py_modules : Sequence [Tuple [str , Any ]],
291293 base_dir : Optional [Sequence [Union [str , pathlib .Path ]]] = None ,
292294 code_url_prefix : Union [Optional [str ], Sequence [Optional [str ]]] = (),
295+ self_link_base : Optional [str ] = None ,
293296 search_hints : bool = True ,
294297 site_path : str = 'api_docs/python' ,
295298 private_map : Optional [Dict [str , str ]] = None ,
296299 visitor_cls : Type [doc_generator_visitor .DocGeneratorVisitor ] = (
297- doc_generator_visitor .DocGeneratorVisitor ),
300+ doc_generator_visitor .DocGeneratorVisitor
301+ ),
298302 api_cache : bool = True ,
299303 callbacks : Optional [List [public_api .ApiFilter ]] = None ,
300304 yaml_toc : Union [bool , Type [toc_lib .TocBuilder ]] = True ,
@@ -315,12 +319,15 @@ def __init__(
315319 in" paths. These are zipped with `base-dir`, to set the `defined_in`
316320 path for each file. The defined in link for `{base_dir}/path/to/file` is
317321 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.
318325 search_hints: Bool. Include metadata search hints at the top of each file.
319326 site_path: Path prefix in the "_toc.yaml"
320327 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.
324331 visitor_cls: An option to override the default visitor class
325332 `doc_generator_visitor.DocGeneratorVisitor`.
326333 api_cache: Bool. Generate an api_cache file. This is used to easily add
@@ -364,10 +371,13 @@ def __init__(
364371 raise ValueError ('`code_url_prefix` cannot be empty' )
365372
366373 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+ )
370379
380+ self ._self_link_base = self_link_base
371381 self ._search_hints = search_hints
372382 self ._site_path = site_path
373383 self ._private_map = private_map or {}
@@ -399,7 +409,9 @@ def make_parser_config(self,
399409 path_tree = visitor .path_tree ,
400410 api_tree = visitor .api_tree ,
401411 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+ )
403415
404416 def run_extraction (self ):
405417 """Walks the module contents, returns an index of all visited objects.
0 commit comments