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

Add API docs #1634

Merged
merged 39 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
205f574
generate api docs
kcpevey Oct 24, 2022
38a80de
add api docs here, add workflow
kcpevey Oct 25, 2022
4f908c8
add temp file
kcpevey Oct 25, 2022
615c41a
linting
kcpevey Oct 25, 2022
98a2576
Merge branch 'release/2022.11.1' into api_docs
aktech Nov 30, 2022
7390150
updates for nebari rename and other minor fixes
kcpevey Dec 14, 2022
aed5ead
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 14, 2022
e59510f
merge conflicts
kcpevey Dec 14, 2022
29ef6e9
remove conda from ci, update readme, finish rename
kcpevey Dec 14, 2022
a64666f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 14, 2022
dc97400
formatting
kcpevey Dec 14, 2022
165d730
allow precommit to error in order to lint
kcpevey Dec 14, 2022
7a4561e
remove setup.cfg to resolve conflict
kcpevey Dec 15, 2022
8b8f817
try continue-on-error
kcpevey Dec 15, 2022
09c153e
move docs requirements into pyproject.toml
kcpevey Dec 15, 2022
c1e338b
security hooha
kcpevey Dec 15, 2022
5e4dca6
modify the watch for changes
kcpevey Dec 15, 2022
23006ad
Update pyproject.toml
kcpevey Jan 23, 2023
59df104
Merge branch 'nebari-dev:develop' into api_docs
kcpevey Jan 31, 2023
2db398b
specify base branch
kcpevey Jan 31, 2023
3418079
cleanup
kcpevey Mar 10, 2023
38e1dd2
Merge branch 'develop' into api_docs
kcpevey Mar 10, 2023
81aebf5
switching to sphinx-click
kcpevey Mar 20, 2023
1d950b8
rename file
kcpevey Mar 20, 2023
9cdaf9e
add sphinx-click docs
kcpevey Mar 20, 2023
5da3cc7
remove old files
kcpevey Mar 20, 2023
ecf27b6
[pre-commit.ci] Apply automatic pre-commit fixes
pre-commit-ci[bot] Mar 20, 2023
bf4e64f
fix precommit hooks
kcpevey Mar 20, 2023
9271c6b
Merge branch 'develop' into api_docs
kcpevey Mar 20, 2023
4e3a7f7
Merge branch 'develop' into api_docs
iameskild Apr 24, 2023
3f1d20b
Merge branch 'develop' into api_docs
iameskild May 1, 2023
bf995fc
Merge branch 'develop' into api_docs
iameskild May 18, 2023
2fef789
merge conflict resolution
kcpevey Aug 3, 2023
385523d
update cli docs
kcpevey Aug 4, 2023
9d8ed8a
[pre-commit.ci] Apply automatic pre-commit fixes
pre-commit-ci[bot] Aug 4, 2023
4be2346
merge conflicts
kcpevey Aug 22, 2023
f63fa0f
updated for changes to cli
kcpevey Aug 22, 2023
b8b269f
[pre-commit.ci] Apply automatic pre-commit fixes
pre-commit-ci[bot] Aug 22, 2023
7b1f3d4
Merge branch 'develop' into api_docs
kcpevey Sep 11, 2023
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
67 changes: 67 additions & 0 deletions .github/workflows/generate_cli_doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Update API docs

on:
pull_request:
push:
branches:
- main
iameskild marked this conversation as resolved.
Show resolved Hide resolved
workflow_dispatch:

jobs:
update_api:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
working-directory: ./docs-sphinx
steps:
- name: Check out repository 🛎️
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.10"

- name: Install nebari and docs dependencies
run: |
python -m pip install --upgrade pip
pip install -e "../[docs]"

- name: Generate new API docs
run: |
make html

- name: Copy cli doc
run: |
cp _build/html/cli.html cli.html

- name: Look for changes to generated docs
uses: tj-actions/verify-changed-files@v12
id: verify-changed-files
with:
files: |
docs-sphinx/cli.html

- name: Create Pull Request in code repo
id: create_pull_request
uses: peter-evans/create-pull-request@v4
if: steps.verify-changed-files.outputs.files_changed == 'true'
with:
token: ${{ secrets.NEBARI_SENSEI_API_DOCS_PR_OPENER }}
commit-message: Update api docs
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: auto_cli_doc_update
delete-branch: true
title: '[AUTO] Update CLI doc'
body: |
Update CLI doc
- Auto-generated by [create-pull-request][1]

[1]: https://github.com/peter-evans/create-pull-request
labels: |
"area: documentation 📖"
draft: false
base: ${{ github.head_ref }}
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ repos:
rev: v4.4.0
hooks:
- id: end-of-file-fixer
exclude: "^docs-sphinx/cli.html"
- id: trailing-whitespace
exclude: "^docs-sphinx/cli.html"
- id: check-json
- id: check-yaml
# jinja2 templates for helm charts
Expand Down
20 changes: 20 additions & 0 deletions docs-sphinx/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
26 changes: 26 additions & 0 deletions docs-sphinx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Nebari CLI documentation

The CLI docs are generated using Sphinx and the sphinx-click extension. Although
a full Sphinx website is required in order to generate the docs, only the
`cli.html` file is used. This file gets copied over to the nebari-docs repo via
a GitHub Action.

## Automation via GitHub Actions

_Generating the CLI HTML file_

A GitHub Action will run with every push to either the `dev` or `main` branches
which generates the documentation. A full Sphinx site build is required. To
build the site, go to the `docs-sphinx` folder and run

`make html`

The Action will then checks to see if `cli.html` (the generated doc) has
changed. If it has changed, it will open a new PR with an updated version.

_Updating the Nebari Docs repo_

The Nebari Documentation lives in a separate repo from the code itself
(https://github.com/nebari-dev/nebari-docs). A separate GitHub Action watches
for changes to the `cli.html` file in _this_ repo, and keeps it in sync with
the `cli.html` file in the docs repo.
681 changes: 681 additions & 0 deletions docs-sphinx/cli.html

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions docs-sphinx/cli.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Nebari CLI
==========

.. click:: nebari.cli.main:typer_click_app
:prog: main
:nested: full
9 changes: 9 additions & 0 deletions docs-sphinx/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
project = "Nebari CLI documentation"
copyright = "2023, Nebari"
author = "Nebari team"

extensions = ["sphinx_click"]

exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

html_theme = "alabaster"
21 changes: 21 additions & 0 deletions docs-sphinx/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. Nebari API documentation documentation master file, created by
sphinx-quickstart on Fri Mar 10 12:28:01 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to Nebari API documentation's documentation!
====================================================

.. toctree::
:maxdepth: 2
:caption: Contents:

.. toctree::
cli

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
3 changes: 3 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,6 @@ yarn-error.log*

app/__pycache__
docs/users.pdf

# docs
docs/api_docs/api_temp.md
8 changes: 7 additions & 1 deletion nebari/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,12 @@ def support(
zip.write(file)


# get the click object from the typer app so that we can autodoc the cli
# NOTE: this must happen _after_ all the subcommands have been added.
# Adapted from https://typer.tiangolo.com/tutorial/using-click/
typer_click_app = typer.main.get_command(app)


def get_config_namespace(config):
config_filename = Path(config)
if not config_filename.is_file():
Expand All @@ -543,4 +549,4 @@ def get_config_namespace(config):


if __name__ == "__main__":
app()
typer_click_app()
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ dev = [
"grayskull",
"build",
]
docs = [
"sphinx",
"sphinx_click",
]

[project.urls]
Documentation = "https://www.nebari.dev/docs"
Expand Down