Skip to content

Commit

Permalink
Build docs with myst instead of rst (#5)
Browse files Browse the repository at this point in the history
* Build docs with myst instead of rst

* Add markdown support to the extension

* Fix file extension check

* Update docs to advertise md support
  • Loading branch information
jacobtomlinson authored Dec 9, 2024
1 parent 78e914b commit 959feab
Show file tree
Hide file tree
Showing 9 changed files with 456 additions and 255 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Features:

- Render documentation from your `Chart.yaml` and `values.yaml` files.
- Sphinx extension for including in Python documentation.
- Works with `rst` and `md` documentation source files.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ["sphinx_helm.ext", "sphinx_click.ext"]
extensions = ["sphinx_helm.ext", "sphinx_click.ext", "myst_parser"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand Down
3 changes: 3 additions & 0 deletions docs/customizing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Customizing your docs

TODO
4 changes: 0 additions & 4 deletions docs/customizing.rst

This file was deleted.

58 changes: 58 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Sphinx-helm

```{toctree}
:maxdepth: 2
:hidden: true
customizing
```

`sphinx-helm` is a [Sphinx](https://www.sphinx-doc.org/) plugin for automatically generating documentation for your [Helm charts](https://helm.sh/).

It will use the chart's `Chart.yaml` and `values.yaml` files in order to
generate the content in a markup language of your choice.

## Features

- Render documentation from your `Chart.yaml` and `values.yaml` files.
- Sphinx extension for including in Python documentation.
- Works with `rst` and `md` documentation source files.

## Installation

```console
$ pip install sphinx-helm
```

## Example

Create an example `hello-world` Helm chart with `helm create`.

```console
$ helm create hello-world
Creating hello-world
```

- Enable the plugin in your Sphinx ``conf.py`` file:

```python
extensions = ['sphinx-helm.ext']
```

- Now you can use the `helm` directive wherever you wish in your documentation.

```rst
.. helm:: path/to/hello-world
```

```{note}
sphinx-helm paths are relative to the root of your documentation.
```

## Example

*The following was autogenerated from the simple nginx example chart in sphinx-helm's test suite.*


```{helm} ../sphinx_helm/tests/mockcharts/simple
```
65 changes: 0 additions & 65 deletions docs/index.rst

This file was deleted.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ test = [
docs = [
"sphinx",
"sphinx-click",
"myst-parser>=3.0.1",
]

[build-system]
Expand Down
6 changes: 5 additions & 1 deletion sphinx_helm/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ def run(self):
self.arguments[0],
)
if self.options.get('output_format') is None:
self.options.update({'output_format': 'rst'})
# if page is being built with myst use markdown
if self.state.document.current_source.endswith('.md'):
self.options.update({'output_format': 'markdown'})
else:
self.options.update({'output_format': 'rst'})
output = ViewList(gen(chart_path, output_format=self.options.get('output_format')).split("\n"))

node = nodes.section()
Expand Down
571 changes: 387 additions & 184 deletions uv.lock

Large diffs are not rendered by default.

0 comments on commit 959feab

Please sign in to comment.