Skip to content

Add documentation with MkDocs #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Deploy docs
on:
workflow_dispatch:
push:
branches:
- 'master'
pull_request:
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
if: (github.event_name != 'pull_request')

- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: |
setup.py
requirements-docs.txt

- name: Save time for cache for mkdocs
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV

- name: Caching
uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-

- name: Install Dependencies
run: pip install -r requirements-docs.txt

- name: Deploy to GitHub Pages
run: mkdocs gh-deploy --force
if: (github.event_name != 'pull_request')

- name: Build docs to check for errors
run: mkdocs build
if: (github.event_name == 'pull_request')
3 changes: 3 additions & 0 deletions docs/api_docs/python/beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TFX-BSL Public Beam

::: tfx_bsl.public.beam
3 changes: 3 additions & 0 deletions docs/api_docs/python/tfxio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TFX-BSL Public TFXIO

::: tfx_bsl.public.tfxio
1 change: 1 addition & 0 deletions docs/images/tf_full_color_primary_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/index.md
19 changes: 19 additions & 0 deletions docs/javascripts/mathjax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
window.MathJax = {
tex: {
inlineMath: [["\\(", "\\)"]],
displayMath: [["\\[", "\\]"]],
processEscapes: true,
processEnvironments: true
},
options: {
ignoreHtmlClass: ".*|",
processHtmlClass: "arithmatex"
}
};

document$.subscribe(() => {
MathJax.startup.output.clearCache()
MathJax.typesetClear()
MathJax.texReset()
MathJax.typesetPromise()
})
42 changes: 42 additions & 0 deletions docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
:root {
--md-primary-fg-color: #FFA800;
--md-primary-fg-color--light: #CCCCCC;
--md-primary-fg-color--dark: #425066;
}

.video-wrapper {
max-width: 240px;
display: flex;
flex-direction: row;
}
.video-wrapper > iframe {
width: 100%;
aspect-ratio: 16 / 9;
}

.buttons-wrapper {
flex-wrap: wrap;
gap: 1em;
display: flex;
/* flex-grow: 1; */
/* justify-content: center; */
/* align-content: center; */
}

.buttons-wrapper > a {
justify-content: center;
align-content: center;
flex-wrap: nowrap;
/* gap: 1em; */
align-items: center;
text-align: center;
flex: 1 1 30%;
display: flex;
}

.md-button > .buttons-content {
align-items: center;
justify-content: center;
display: flex;
gap: 1em;
}
118 changes: 118 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
site_name: TFX Basic Shared Libraries
repo_name: "tfx-bsl"
repo_url: https://github.com/tensorflow/tfx-bsl

theme:
logo: images/tf_full_color_primary_icon.svg
name: material
palette:
# Palette toggle for automatic mode
- media: "(prefers-color-scheme)"
primary: custom
accent: custom
toggle:
icon: material/brightness-auto
name: Switch to light mode

# Palette toggle for light mode
- media: "(prefers-color-scheme: light)"
primary: custom
accent: custom
scheme: default
toggle:
icon: material/brightness-7
name: Switch to dark mode

# Palette toggle for dark mode
- media: "(prefers-color-scheme: dark)"
primary: custom
accent: custom
scheme: slate
toggle:
icon: material/brightness-4
name: Switch to system preference
favicon: images/tf_full_color_primary_icon.svg

features:
- content.code.copy
- content.code.select
- content.action.edit

plugins:
- search
- autorefs
- mkdocstrings:
default_handler: python
handlers:
python:
options:
show_source: true
show_root_heading: true
unwrap_annotated: true
show_symbol_type_toc: true
show_if_no_docstring: true
show_symbol_type_heading: true
merge_init_into_class: true
show_signature_annotations: true
separate_signature: true
signature_crossrefs: true
group_by_category: true
show_category_heading: true
show_submodules: true
show_root_full_path: true
docstring_section_style: "spacy"
inherited_members: true
summary: false
filters:
- "!^_"
- "^__init__$"
- "^__call__$"
- "!^logger"
- "!^test_"
- "!_test$"
extensions:
- griffe_inherited_docstrings
import:
- https://docs.python.org/3/objects.inv

extra_css:
- stylesheets/extra.css

extra_javascript:
- javascripts/mathjax.js
- https://unpkg.com/mathjax@3/es5/tex-mml-chtml.js

markdown_extensions:
- admonition
- attr_list
- def_list
- tables
- toc:
permalink: true
- pymdownx.highlight:
anchor_linenums: true
linenums: false
line_spans: __span
pygments_lang_class: true
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.superfences
- pymdownx.arithmatex:
generic: true
- pymdownx.critic
- pymdownx.caret
- pymdownx.keys
- pymdownx.mark
- pymdownx.tilde
- md_in_html
- pymdownx.emoji:
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
watch:
- tfx_bsl

nav:
- Home: index.md
- API Docs:
- tfx_bsl.public.beam: api_docs/python/beam.md
- tfx_bsl.public.tfxio: api_docs/python/tfxio.md
6 changes: 6 additions & 0 deletions requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mkdocs
mkdocs-material
mkdocstrings[python]
griffe-inherited-docstrings
mkdocs-autorefs
ruff
11 changes: 11 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""Package Setup script for TFX BSL."""

import os
from pathlib import Path
import platform
import shutil
import subprocess
Expand Down Expand Up @@ -201,6 +202,16 @@ def select_constraint(default, nightly=None, git_master=None):
git_master='@git+https://github.com/tensorflow/serving@master',
),
],
extras_require = {
"docs" : [
req for req in Path("./requirements-docs.txt")
.expanduser()
.resolve()
.read_text()
.splitlines()
if req
]
},
python_requires='>=3.9,<4',
packages=find_packages(),
include_package_data=True,
Expand Down
4 changes: 4 additions & 0 deletions tfx_bsl/public/beam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@
"""Module level imports for tfx_bsl.beam."""

from tfx_bsl.public.beam.run_inference import RunInference

__all__ = [
"RunInference",
]
18 changes: 18 additions & 0 deletions tfx_bsl/public/tfxio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,21 @@
from tfx_bsl.tfxio.tf_sequence_example_record import TFSequenceExampleBeamRecord
from tfx_bsl.tfxio.tf_sequence_example_record import TFSequenceExampleRecord
from tfx_bsl.tfxio.tfxio import TFXIO


__all__ = [
"BeamRecordCsvTFXIO",
"CsvTFXIO",
"RecordBatchToExamplesEncoder",
"RecordBatchesOptions",
"TFExampleBeamRecord",
"TFExampleRecord",
"TFGraphRecordDecoder",
"TFSequenceExampleBeamRecord",
"TFSequenceExampleRecord",
"TFXIO",
"TensorAdapter",
"TensorAdapterConfig",
"TensorFlowDatasetOptions",
"TensorRepresentations",
]
20 changes: 19 additions & 1 deletion tfx_bsl/tfxio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,23 @@
"""Package tfxio contains the implementation of Standardized TFX inputs.

Design doc:
https://github.com/tensorflow/community/blob/master/rfcs/20191017-tfx-standardized-inputs.md
[https://github.com/tensorflow/community/blob/master/rfcs/20191017-tfx-standardized-inputs.md](https://github.com/tensorflow/community/blob/master/rfcs/20191017-tfx-standardized-inputs.md)
"""


__all__ = [
"BeamRecordCsvTFXIO",
"CsvTFXIO",
"RecordBatchToExamplesEncoder",
"RecordBatchesOptions",
"TFExampleBeamRecord",
"TFExampleRecord",
"TFGraphRecordDecoder",
"TFSequenceExampleBeamRecord",
"TFSequenceExampleRecord",
"TFXIO",
"TensorAdapter",
"TensorAdapterConfig",
"TensorFlowDatasetOptions",
"TensorRepresentations",
]
Loading