Skip to content

Commit 6914e83

Browse files
MarkDaoustcopybara-github
authored andcommitted
Move pageInfo and pageBuilder classes into corresponding files.
1. Split pretty_docs.py into into a sub-package. 2. Move: ClassPageInfo + ClassPageBuilder + supporting functions -> class_page.py 3. Do the same for function, module, and type_alias 6. Replace: pretty_docs.build_md_page() -> page_info.build() 7. Everything else is just renames to make that work. Pure refactor. No behavior changes. PiperOrigin-RevId: 420156326
1 parent 01d385d commit 6914e83

24 files changed

+1819
-1716
lines changed

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
recursive-include tools/tensorflow_docs/api_generator/gen_java/ *
2-
recursive-include tools/tensorflow_docs/api_generator/templates/ *
2+
recursive-include tools/tensorflow_docs/api_generator/pretty_docs/templates/ *

tools/tensorflow_docs/api_generator/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from tensorflow_docs.api_generator import doc_generator_visitor
2020
from tensorflow_docs.api_generator import generate_lib
2121
from tensorflow_docs.api_generator import parser
22-
from tensorflow_docs.api_generator import pretty_docs
2322
from tensorflow_docs.api_generator import public_api
2423
from tensorflow_docs.api_generator import traverse
2524
from tensorflow_docs.api_generator import utils

tools/tensorflow_docs/api_generator/generate_lib.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@
2929
from tensorflow_docs.api_generator import doc_controls
3030
from tensorflow_docs.api_generator import doc_generator_visitor
3131
from tensorflow_docs.api_generator import parser
32-
from tensorflow_docs.api_generator import pretty_docs
3332
from tensorflow_docs.api_generator import public_api
3433
from tensorflow_docs.api_generator import reference_resolver as reference_resolver_lib
3534
from tensorflow_docs.api_generator import signature
3635
from tensorflow_docs.api_generator import traverse
36+
from tensorflow_docs.api_generator.pretty_docs import base_page
37+
38+
from tensorflow_docs.api_generator.pretty_docs import docs_for_object
39+
3740
from tensorflow_docs.api_generator.report import utils
3841

3942
import yaml
@@ -434,7 +437,8 @@ def generate(self) -> Dict[str, Any]:
434437
return {'toc': toc}
435438

436439

437-
def _get_headers(page_info: parser.PageInfo, search_hints: bool) -> List[str]:
440+
def _get_headers(page_info: base_page.PageInfo,
441+
search_hints: bool) -> List[str]:
438442
"""Returns the list of header lines for this page."""
439443
hidden = doc_controls.should_hide_from_search(page_info.py_object)
440444
brief_no_backticks = page_info.doc.brief.replace('`', '').strip()
@@ -559,8 +563,8 @@ def write_docs(
559563

560564
# Generate docs for `py_object`, resolving references.
561565
try:
562-
page_info = parser.docs_for_object(full_name, py_object, parser_config,
563-
extra_docs)
566+
page_info = docs_for_object.docs_for_object(full_name, py_object,
567+
parser_config, extra_docs)
564568
if gen_report and not full_name.startswith(
565569
('tf.compat.v', 'tf.keras.backend', 'tf.numpy',
566570
'tf.experimental.numpy')):
@@ -572,7 +576,7 @@ def write_docs(
572576
path = output_dir / parser.documentation_path(full_name)
573577

574578
content = _get_headers(page_info, search_hints)
575-
content.append(pretty_docs.build_md_page(page_info))
579+
content.append(page_info.build())
576580
text = '\n'.join(content)
577581
try:
578582
path.parent.mkdir(exist_ok=True, parents=True)

tools/tensorflow_docs/api_generator/generate_lib_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from tensorflow_docs.api_generator import generate_lib
3030
from tensorflow_docs.api_generator import parser
3131
from tensorflow_docs.api_generator import reference_resolver as reference_resolver_lib
32+
from tensorflow_docs.api_generator.pretty_docs import function_page
3233

3334
import yaml
3435

@@ -187,9 +188,9 @@ def test_write(self):
187188
self.assertTrue((output_dir / 'tf/TestModule/test_function.md').exists())
188189

189190
def _get_test_page_info(self):
190-
page_info = parser.FunctionPageInfo(
191+
page_info = function_page.FunctionPageInfo(
191192
full_name='abc', py_object=test_function)
192-
docstring_info = parser._DocstringInfo(
193+
docstring_info = parser.DocstringInfo(
193194
brief='hello `tensorflow`',
194195
docstring_parts=['line1', 'line2'],
195196
compatibility={})

0 commit comments

Comments
 (0)