Skip to content

Commit c5dc4ff

Browse files
MarkDaoustcopybara-github
authored andcommitted
Collect the page info and builder classes into the root module.
PiperOrigin-RevId: 423357060
1 parent 9fbb00b commit c5dc4ff

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

tools/tensorflow_docs/api_generator/pretty_docs/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,19 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
# ==============================================================================
16+
17+
from tensorflow_docs.api_generator.pretty_docs.base_page import PageBuilder
18+
from tensorflow_docs.api_generator.pretty_docs.base_page import PageInfo
19+
from tensorflow_docs.api_generator.pretty_docs.base_page import TemplatePageBuilder
20+
21+
from tensorflow_docs.api_generator.pretty_docs.class_page import ClassPageBuilder
22+
from tensorflow_docs.api_generator.pretty_docs.class_page import ClassPageInfo
23+
24+
from tensorflow_docs.api_generator.pretty_docs.function_page import FunctionPageBuilder
25+
from tensorflow_docs.api_generator.pretty_docs.function_page import FunctionPageInfo
26+
27+
from tensorflow_docs.api_generator.pretty_docs.module_page import ModulePageBuilder
28+
from tensorflow_docs.api_generator.pretty_docs.module_page import ModulePageInfo
29+
30+
from tensorflow_docs.api_generator.pretty_docs.type_alias_page import TypeAliasPageBuilder
31+
from tensorflow_docs.api_generator.pretty_docs.type_alias_page import TypeAliasPageInfo

tools/tensorflow_docs/api_generator/pretty_docs/base_page.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@
2525

2626
import jinja2
2727

28-
JINJA_ENV = jinja2.Environment(
29-
trim_blocks=True,
30-
lstrip_blocks=True,
31-
loader=jinja2.FileSystemLoader(str(pathlib.Path(__file__).parent)))
32-
3328

3429
class PageBuilder(abc.ABC):
3530

@@ -42,10 +37,17 @@ def build(self) -> str:
4237

4338

4439
class TemplatePageBuilder(PageBuilder):
40+
"""A Page builder implemented on a jinja template."""
41+
4542
TEMPLATE = 'templates/page.jinja'
43+
TEMPLATE_SEARCH_PATH = tuple([str(pathlib.Path(__file__).parent)])
44+
JINJA_ENV = jinja2.Environment(
45+
trim_blocks=True,
46+
lstrip_blocks=True,
47+
loader=jinja2.FileSystemLoader(TEMPLATE_SEARCH_PATH))
4648

4749
def build(self) -> str:
48-
template = JINJA_ENV.get_template(self.TEMPLATE)
50+
template = self.JINJA_ENV.get_template(self.TEMPLATE)
4951
content = template.render(builder=self, page_info=self.page_info)
5052
return content
5153

0 commit comments

Comments
 (0)