Skip to content

Commit 83f9b1f

Browse files
Build documentation with mkdocs (#38)
* Add minimum viable mkdocs configuration * Add examples section * Add links to api docs and overviews * Get api docs up and running * Add `__all__` to `__init__.py` files to include correct classes This is just a first step to including the correct items in the api docs * Exclude test modules from docs * Use correct module * Add docs deployment workflow * Include all correct modules/classes/functions * Fix button rendering * Fix formatting, including admonitions * Fix broken link * Use README.md as homepage for docs * Fix links * Remove debug triggers from docs deployment workflow * Remove deprecated api docs * Fix triggers * Move docs requirements to common location * Only trigger on pushes to master * Remove unnecessary newline characters * Move docs location to default `docs` directory
1 parent dd7a252 commit 83f9b1f

File tree

130 files changed

+2846
-17640
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+2846
-17640
lines changed

.github/workflows/cd-docs.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: deploy-docs
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
push:
6+
branches:
7+
- 'master'
8+
permissions:
9+
contents: write
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repo
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python 3.12
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.12'
21+
cache: 'pip'
22+
cache-dependency-path: |
23+
setup.py
24+
25+
- name: Save time for cache for mkdocs
26+
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
27+
28+
- name: Caching
29+
uses: actions/cache@v4
30+
with:
31+
key: mkdocs-material-${{ env.cache_id }}
32+
path: .cache
33+
restore-keys: |
34+
mkdocs-material-
35+
36+
- name: Install Dependencies
37+
run: pip install -r requirements-docs.txt
38+
39+
- name: Deploy to GitHub Pages
40+
if: (github.event_name != 'pull_request')
41+
run: |
42+
git config user.name github-actions[bot]
43+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
44+
mkdocs gh-deploy --force
45+
46+
- name: Build docs to check for errors
47+
if: (github.event_name == 'pull_request')
48+
run: |
49+
mkdocs build

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ examples of struct2tensor in action and an introduction to the main
1616
concepts. You can
1717
[run the notebook in your browser](https://colab.research.google.com/github/google/struct2tensor/blob/master/examples/prensor_playground.ipynb)
1818
through Google's colab environment, or [download the
19-
file](examples/prensor_playground.ipynb) to run it in your own Jupyter
19+
file](https://github.com/google/struct2tensor/tree/master/g3doc/examples/prensor_playground.ipynb) to run it in your own Jupyter
2020
environment.
2121

2222

@@ -99,8 +99,9 @@ struct2tensor needs a couple of custom TensorFlow ops to function. If you train
9999
a model with struct2tensor and wants to serve it with TensorFlow Serving, the
100100
TensorFlow Serving binary needs to link with those custom ops. We have a
101101
pre-built docker image that contains such a binary. The `Dockerfile` is
102-
available at `tools/tf_serving_docker/Dockerfile`. The image is available at
103-
`gcr.io/tfx-oss-public/s2t_tf_serving`.
102+
available at [`tools/tf_serving_docker/Dockerfile`](https://github.com/google/struct2tensor/blob/master/struct2tensor/tools/tf_serving_docker/Dockerfile).
103+
The image is available at
104+
[`gcr.io/tfx-oss-public/s2t_tf_serving`](gcr.io/tfx-oss-public/s2t_tf_serving).
104105

105106
Please see the `Dockerfile` for details. But in brief, the image exposes port
106107
8500 as the gRPC endpoint and port 8501 as the REST endpoint. You can set
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `expression_impl`
2+
3+
::: struct2tensor.expression_impl
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Module: expression_impl
2+
3+
<div class="buttons-wrapper">
4+
<a class="md-button" target="_blank" href=
5+
"https://github.com/google/struct2tensor/blob/master/struct2tensor/expression_impl/__init__.py">
6+
<div class="buttons-content">
7+
<img width="32px" src=
8+
"https://www.tensorflow.org/images/GitHub-Mark-32px.png">
9+
View source on GitHub
10+
</div>
11+
</a>
12+
</div>
13+
14+
The modules in this file should be accessed like the following:
15+
16+
```python
17+
import struct2tensor as s2t
18+
from struct2tensor import expression_impl
19+
20+
s2t.expression_impl.apply_schema
21+
```
22+
23+
## Modules
24+
25+
[`apply_schema`][struct2tensor.expression_impl.apply_schema] module: Apply a schema to an expression.
26+
27+
[`broadcast`][struct2tensor.expression_impl.broadcast] module: Methods for broadcasting a path in a tree.
28+
29+
[`depth_limit`][struct2tensor.expression_impl.depth_limit] module: Caps the depth of an expression.
30+
31+
[`filter_expression`][struct2tensor.expression_impl.filter_expression] module: Create a new expression that is a filtered version of an original one.
32+
33+
[`index`][struct2tensor.expression_impl.index] module: get_positional_index and get_index_from_end methods.
34+
35+
[`map_prensor`][struct2tensor.expression_impl.map_prensor] module: Arbitrary operations from sparse and ragged tensors to a leaf field.
36+
37+
[`map_prensor_to_prensor`][struct2tensor.expression_impl.map_prensor_to_prensor] module: Arbitrary operations from prensors to prensors in an expression.
38+
39+
[`map_values`][struct2tensor.expression_impl.map_values] module: Maps the values of various leaves of the same child to a single result.
40+
41+
[`parquet`][struct2tensor.expression_impl.parquet] module: Apache Parquet Dataset.
42+
43+
[`placeholder`][struct2tensor.expression_impl.placeholder] module: Placeholder expression.
44+
45+
[`project`][struct2tensor.expression_impl.project] module: project selects a subtree of an expression.
46+
47+
[`promote`][struct2tensor.expression_impl.promote] module: Promote an expression to be a child of its grandparent.
48+
49+
[`promote_and_broadcast`][struct2tensor.expression_impl.promote_and_broadcast] module: promote_and_broadcast a set of nodes.
50+
51+
[`proto`][struct2tensor.expression_impl.proto] module: Expressions to parse a proto.
52+
53+
[`reroot`][struct2tensor.expression_impl.reroot] module: Reroot to a subtree, maintaining an input proto index.
54+
55+
[`size`][struct2tensor.expression_impl.size] module: Functions for creating new size or has expression.
56+
57+
[`slice_expression`][struct2tensor.expression_impl.slice_expression] module: Implementation of slice.
58+

docs/api_docs/python/s2t/index.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Module: s2t
2+
3+
<div class="buttons-wrapper">
4+
<a class="md-button" target="_blank" href=
5+
"https://github.com/google/struct2tensor/blob/master/struct2tensor/__init__.py">
6+
<div class="buttons-content">
7+
<img width="32px" src=
8+
"https://www.tensorflow.org/images/GitHub-Mark-32px.png">
9+
View source on GitHub
10+
</div>
11+
</a>
12+
</div>
13+
14+
Import core names for struct2tensor.
15+
16+
## Classes
17+
18+
[`class ChildNodeTensor`][struct2tensor.ChildNodeTensor]: The value of an intermediate node.
19+
20+
[`class Expression`][struct2tensor.Expression]: An expression represents the calculation of a prensor object.
21+
22+
[`class LeafNodeTensor`][struct2tensor.LeafNodeTensor]: The value of a leaf node.
23+
24+
[`class Path`][struct2tensor.Path]: A representation of a path in the expression.
25+
26+
[`class Prensor`][struct2tensor.Prensor]: A expression of NodeTensor objects.
27+
28+
[`class RootNodeTensor`][struct2tensor.RootNodeTensor]: The value of the root.
29+
30+
## Functions
31+
32+
[`calculate_prensors(...)`][struct2tensor.calculate_prensors]: Gets the prensor value of the expressions.
33+
34+
[`calculate_prensors_with_graph(...)`][struct2tensor.calculate_prensors_with_graph]: Gets the prensor value of the expressions and the graph used.
35+
36+
[`calculate_prensors_with_source_paths(...)`][struct2tensor.calculate_prensors_with_source_paths]: Returns a list of prensor trees, and proto summaries.
37+
38+
[`create_expression_from_file_descriptor_set(...)`][struct2tensor.create_expression_from_file_descriptor_set]: Create an expression from a 1D tensor of serialized protos.
39+
40+
[`create_expression_from_prensor(...)`][struct2tensor.create_expression_from_prensor]: Gets an expression representing the prensor.
41+
42+
[`create_expression_from_proto(...)`][struct2tensor.create_expression_from_proto]: Create an expression from a 1D tensor of serialized protos.
43+
44+
[`create_path(...)`][struct2tensor.create_path]: Create a path from an object.
45+
46+
[`create_prensor_from_descendant_nodes(...)`][struct2tensor.create_prensor_from_descendant_nodes]: Create a prensor from a map of paths to NodeTensor.
47+
48+
[`create_prensor_from_root_and_children(...)`][struct2tensor.create_prensor_from_root_and_children]
49+
50+
[`get_default_options(...)`][struct2tensor.get_default_options]: Get the default options.
51+
52+
[`get_options_with_minimal_checks(...)`][struct2tensor.get_options_with_minimal_checks]: Options for calculation with minimal runtime checks.
53+
54+
[`get_ragged_tensor(...)`][struct2tensor.get_ragged_tensor]: Get a ragged tensor for a path. (deprecated)
55+
56+
[`get_ragged_tensors(...)`][struct2tensor.get_ragged_tensors]: Gets ragged tensors for all the leaves of the prensor expression. (deprecated)
57+
58+
[`get_sparse_tensor(...)`][struct2tensor.get_sparse_tensor]: Gets a sparse tensor for path p. (deprecated)
59+
60+
[`get_sparse_tensors(...)`][struct2tensor.get_sparse_tensors]: Gets sparse tensors for all the leaves of the prensor expression. (deprecated)
61+
62+
## Type Aliases
63+
64+
[`NodeTensor`][struct2tensor.NodeTensor]
65+
66+
[`Step`][struct2tensor.Step]
67+

docs/api_docs/python/s2t/s2t.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# `s2t`
2+
3+
::: struct2tensor.struct2tensor
4+
61.2 KB
Loading

docs/assets/favicon.png

404 Bytes
Loading

0 commit comments

Comments
 (0)