Skip to content

Commit bcbfcc8

Browse files
bzantiumcopybara-github
authored andcommitted
Cloned from bzantium's contribution on ArrayRecord docs.
Doc updates are in the next CL. PiperOrigin-RevId: 836680555
1 parent 769e028 commit bcbfcc8

17 files changed

+5252
-0
lines changed

docs/Makefile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= python3.10 -m sphinx
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Install dependencies
18+
install:
19+
pip install -r requirements.txt
20+
21+
# Build HTML documentation
22+
html:
23+
@$(SPHINXBUILD) -b html "$(SOURCEDIR)" "$(BUILDDIR)/html" $(SPHINXOPTS) $(O)
24+
@echo
25+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
26+
27+
# Build PDF documentation (requires LaTeX)
28+
latexpdf:
29+
@$(SPHINXBUILD) -b latexpdf "$(SOURCEDIR)" "$(BUILDDIR)/latex" $(SPHINXOPTS) $(O)
30+
@echo
31+
@echo "Build finished; the PDF files are in $(BUILDDIR)/latex."
32+
33+
# Clean build directory
34+
clean:
35+
rm -rf "$(BUILDDIR)"
36+
37+
# Live reload server for development
38+
livehtml:
39+
sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)/html" $(SPHINXOPTS) $(O)
40+
41+
# Check for broken links
42+
linkcheck:
43+
@$(SPHINXBUILD) -b linkcheck "$(SOURCEDIR)" "$(BUILDDIR)/linkcheck" $(SPHINXOPTS) $(O)
44+
@echo
45+
@echo "Link check complete; look for any errors in the above output " \
46+
"or in $(BUILDDIR)/linkcheck/output.txt."
47+
48+
# Check spelling (requires sphinxcontrib-spelling)
49+
spelling:
50+
@$(SPHINXBUILD) -b spelling "$(SOURCEDIR)" "$(BUILDDIR)/spelling" $(SPHINXOPTS) $(O)
51+
@echo
52+
@echo "Spelling check complete; look for any errors in the above output " \
53+
"or in $(BUILDDIR)/spelling/output.txt."
54+
55+
# Build all formats
56+
all: html latexpdf
57+
58+
# Development setup
59+
dev-setup: install
60+
pip install sphinx-autobuild sphinxcontrib-spelling
61+
62+
# Catch-all target: route all unknown targets to Sphinx using the new
63+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
64+
%: Makefile
65+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/README.md

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
# ArrayRecord Documentation
2+
3+
This directory contains the Sphinx documentation for ArrayRecord.
4+
5+
## Building the Documentation
6+
7+
### Prerequisites
8+
9+
Install the documentation dependencies:
10+
11+
```bash
12+
pip install -r requirements.txt
13+
```
14+
15+
### Build HTML Documentation
16+
17+
```bash
18+
# Using Sphinx directly
19+
sphinx-build -b html . _build/html
20+
21+
# Or using the Makefile
22+
make html
23+
```
24+
25+
The generated HTML documentation will be in `_build/html/`. Open `_build/html/index.html` in your browser to view it.
26+
27+
### Development Workflow
28+
29+
For development with live reload:
30+
31+
```bash
32+
# Install additional development dependencies
33+
pip install sphinx-autobuild
34+
35+
# Start live reload server
36+
sphinx-autobuild . _build/html
37+
```
38+
39+
This will start a local server (usually at http://127.0.0.1:8000) that automatically rebuilds and reloads when you make changes.
40+
41+
### Other Formats
42+
43+
Build PDF documentation (requires LaTeX):
44+
45+
```bash
46+
make latexpdf
47+
```
48+
49+
Check for broken links:
50+
51+
```bash
52+
make linkcheck
53+
```
54+
55+
## Documentation Structure
56+
57+
```
58+
docs/
59+
├── conf.py # Sphinx configuration
60+
├── index.rst # Main documentation index
61+
├── installation.md # Installation guide
62+
├── quickstart.md # Quick start guide
63+
├── core_concepts.md # Core concepts explanation
64+
├── performance.md # Performance optimization guide
65+
├── examples.md # Comprehensive examples
66+
├── beam_integration.md # Apache Beam integration guide
67+
├── contributing.md # Contribution guidelines
68+
├── changelog.md # Version changelog
69+
├── python_reference.rst # Python API reference
70+
├── beam_reference.rst # Beam API reference
71+
├── cpp_reference.rst # C++ API reference
72+
├── requirements.txt # Documentation dependencies
73+
├── Makefile # Build automation
74+
└── README.md # This file
75+
```
76+
77+
## Writing Documentation
78+
79+
### Markdown vs reStructuredText
80+
81+
- Use **Markdown (.md)** for user guides, tutorials, and narrative documentation
82+
- Use **reStructuredText (.rst)** for API references and when you need advanced Sphinx features
83+
84+
### Style Guidelines
85+
86+
1. **Use clear, concise language**
87+
2. **Include code examples** for all features
88+
3. **Provide context** for when to use different options
89+
4. **Link between related sections**
90+
5. **Keep examples up-to-date** with the current API
91+
92+
### Code Examples
93+
94+
Always include working code examples:
95+
96+
```python
97+
from array_record.python import array_record_module
98+
99+
# Create a writer
100+
writer = array_record_module.ArrayRecordWriter('example.array_record')
101+
writer.write(b'Hello, ArrayRecord!')
102+
writer.close()
103+
```
104+
105+
### Cross-References
106+
107+
Use Sphinx cross-references to link between sections:
108+
109+
- `:doc:`installation`` - Link to installation.md
110+
- `:ref:`section-label`` - Link to a labeled section
111+
- `:class:`array_record.python.array_record_module.ArrayRecordWriter`` - Link to class
112+
113+
### API Documentation
114+
115+
API documentation is auto-generated from docstrings. Ensure all public APIs have comprehensive docstrings:
116+
117+
```python
118+
def my_function(param1: str, param2: int = 0) -> bool:
119+
"""Brief description of the function.
120+
121+
Longer description with more details about the function's behavior,
122+
use cases, and any important considerations.
123+
124+
Args:
125+
param1: Description of the first parameter.
126+
param2: Description of the second parameter. Defaults to 0.
127+
128+
Returns:
129+
Description of what the function returns.
130+
131+
Raises:
132+
ValueError: Description of when this exception is raised.
133+
134+
Example:
135+
>>> result = my_function("test", 42)
136+
>>> print(result)
137+
True
138+
"""
139+
pass
140+
```
141+
142+
## Contributing to Documentation
143+
144+
1. **Check existing documentation** before adding new content
145+
2. **Follow the style guidelines** above
146+
3. **Test your changes** by building the documentation locally
147+
4. **Update the table of contents** if adding new pages
148+
5. **Check for broken links** using `make linkcheck`
149+
150+
### Adding New Pages
151+
152+
1. Create the new file (`.md` or `.rst`)
153+
2. Add it to the appropriate `toctree` in `index.rst`
154+
3. Update cross-references as needed
155+
4. Test the build
156+
157+
### Updating API Documentation
158+
159+
API documentation is automatically generated from docstrings. To update:
160+
161+
1. Modify the docstrings in the source code
162+
2. Rebuild the documentation
163+
3. Check that the changes appear correctly
164+
165+
## Troubleshooting
166+
167+
### Common Issues
168+
169+
1. **Import errors during build**: Ensure ArrayRecord is installed in your environment
170+
2. **Missing dependencies**: Install requirements with `pip install -r requirements.txt`
171+
3. **Build warnings**: Address warnings as they often indicate real issues
172+
4. **Broken links**: Use `make linkcheck` to identify and fix broken links
173+
174+
### Clean Builds
175+
176+
If you encounter issues, try a clean build:
177+
178+
```bash
179+
make clean
180+
make html
181+
```
182+
183+
### Debugging Sphinx
184+
185+
Enable verbose output to debug issues:
186+
187+
```bash
188+
sphinx-build -v -b html . _build/html
189+
```
190+
191+
## Deployment
192+
193+
The documentation is typically built and deployed automatically via CI/CD. For manual deployment:
194+
195+
1. Build the documentation: `make html`
196+
2. Upload the `_build/html` directory to your web server
197+
3. Ensure proper permissions and web server configuration
198+
199+
## Resources
200+
201+
- [Sphinx Documentation](https://www.sphinx-doc.org/)
202+
- [reStructuredText Primer](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html)
203+
- [MyST Parser (Markdown)](https://myst-parser.readthedocs.io/)
204+
- [Read the Docs Sphinx Theme](https://sphinx-rtd-theme.readthedocs.io/)

0 commit comments

Comments
 (0)