Skip to content
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

Documentation #147

Merged
merged 7 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
37 changes: 37 additions & 0 deletions .github/workflows/publish-document.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish document
on:
push:
branches:
- master
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need master in here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Removed with this commit 89b0527.

- main
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout Repository
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
- uses: actions/setup-python@v5
name: Setup Python
with:
python-version: 3.12
- name: Set Cache ID
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Restore/Save Cache
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- name: Install MkDocs Dependencies
run: |
pip install mkdocs-material
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would great to put all of this into pyproject.toml as an additional dev dependency set and then add a script in scripts to run the generation locally. This would allow us to dry-run docs easily locally which would be really useful if this docs section grows beyond auto-generated API references.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the advice!

I have updated pyproject.toml, tox.ini and added a shell script scripts/document.sh. Now, user can just run tox -e docs to build the current documentation, or tox -e docs -- serve to view the docs locally. 457dbf4

.github/workflows/publish-document.yml also uses tox command to publish the documentation. 4b27576

pip install 'mkdocstrings[python]'
- name: Deploy to GitHub Pages
run: mkdocs gh-deploy --force
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ venv/

# Setuptools scm version
_version.py

# mkdocs documentation
/site
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to remove the leading / since I'm guessing this absolute path is only correct if developing inside a docker container

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry, but I don't understand which docker container you are mentioning.

I do not use docker container for my development environment. I simply followed CONTRIBUTION.md, and it does not have any description for docker.

And when I build the document with mkdocs build command, it outputs the document into /site folder, so I updated gitignore to ignore this directory.

Is there a way to create the development environment with docker?

25 changes: 25 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,31 @@ To format and lint the codes,
tox -e fmt,lint
```

## [Optional] Documentation setup

This repository uses [mkdocs](https://github.com/mkdocs/mkdocs/tree/master) to generate a documentation from python docstring. As long as you write docstrings for your code, the document (API references section) will be automatically updated when the code is merged into `main` branch, so there is no need for you to do anything.

If you want to manually edit the document, please run the following commands to setup the editing environment.

```bash
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do go the route or scripting and tracking deps in pyproject this will need to be updated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have to chose this route. Please check #147 (comment)

pip install mkdocs-material
pip install 'mkdocstrings[python]'
```

You can edit the documentation at `docs` folder (i.e. `docs/index.md`) to update the document.

In order to view the current documentation locally, run the following command. This will host the document at your local server.

```bash
mkdocs serve
```

For more information about mkdocs, please refer to their documentations:

- mkdocs: https://github.com/mkdocs/mkdocs/tree/master
- mkdocs material (material theme wrapper for mkdocs): https://github.com/squidfunk/mkdocs-material
- mkdocstrings (plugin to automatically generate documentation from docstrings): https://github.com/mkdocstrings/mkdocstrings

# Your First Contribution

Would you like to help drive the community forward? We will help you understand the organization of the project and direct you to the best places to get started. You'll be able to pick up issues, write code to fix them, and get your work reviewed and merged.
Expand Down
3 changes: 3 additions & 0 deletions docs/API References.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- Auto generate API references with mkdocstrings https://mkdocstrings.github.io/usage/#usage -->

::: oper8
5 changes: 5 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Oper8

Oper8 is a framework for writing kubernetes operators in python. It implements many common patterns used by large cloud applications that are reusable across many operator design patterns ([GitHub](https://github.com/IBM/oper8/tree/main)).

For API details, please refer to the [API References](API References.md).
31 changes: 31 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
site_name: "oper8"
nav:
- Home: index.md
- API References: API References.md
theme:
name: material
font:
text: IBM Plex Sans
code: IBM Plex Mono
palette:
# Dark Mode
- scheme: slate
toggle:
icon: material/weather-sunny
name: Dark mode
primary: black
accent: deep purple
# Light Mode
- scheme: default
toggle:
icon: material/weather-night
name: Light mode
primary: white
accent: indigo
plugins:
- search
- mkdocstrings:
handlers:
python:
options:
show_submodules: true
Loading