Skip to content

Commit 48972c1

Browse files
committed
Initial support to generate local documentation
1 parent b1bf11b commit 48972c1

File tree

7 files changed

+107
-0
lines changed

7 files changed

+107
-0
lines changed

docs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build
2+
__pycache__

docs/Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 ?= sphinx-build
8+
SOURCEDIR = ../website/docs
9+
BUILDDIR = build
10+
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
11+
12+
# Put it first so that "make" without argument is like "make help".
13+
help:
14+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
15+
16+
.PHONY: help Makefile
17+
18+
# Catch-all target: route all unknown targets to Sphinx using the new
19+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
20+
%: Makefile
21+
@$(SPHINXBUILD) -b $@ -c $(ROOT_DIR) "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
# Generating documentation
3+
4+
Requirements:
5+
6+
* Sphinx
7+
* Python recommonmark
8+
* sphinx_rtd_theme
9+
10+
Then do:
11+
12+
```
13+
make html
14+
```
15+

docs/conf.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# -*- coding: utf-8 -*-
2+
import subprocess
3+
import os
4+
import sys
5+
sys.path.insert(0, os.path.abspath('.'))
6+
from recommonmark.transform import AutoStructify
7+
8+
project = 'terraform-provider-libvirt'
9+
copyright = '2019, Duncan Mac-Vicar P. & contributors'
10+
author = 'Duncan Mac-Vicar P.'
11+
12+
version = subprocess.check_output(('git', 'describe', '--tags')).decode("utf-8")
13+
14+
source_suffix = {
15+
'.html.markdown': 'markdown',
16+
}
17+
18+
templates_path = ['_templates']
19+
exclude_patterns = ["_build"]
20+
html_theme = 'sphinx_rtd_theme'
21+
extensions = ['removefrontmatter','recommonmark']
22+
23+
html_theme_options = {
24+
'collapse_navigation': False,
25+
}
26+
27+
master_doc = 'toc'
28+
29+
def setup(app):
30+
app.add_config_value('recommonmark_config', {
31+
'enable_eval_rst': True,
32+
'auto_toc_tree_section': 'Resources',
33+
'auto_toc_maxdepth': 3,
34+
'commonmark_suffixes': ['.html.markdown'],
35+
}, 'env')
36+
app.add_transform(AutoStructify)
37+
38+

docs/removefrontmatter.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import re
2+
3+
# Remove the frint matter (YAML) from markdown files
4+
def source_read_handler(app, docname, source):
5+
source[0] = re.sub(r'^---\n(.+\n)*---\n', '', source[0])
6+
7+
def setup(app):
8+
app.connect('source-read', source_read_handler)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
# Resources
3+
4+
```eval_rst
5+
.. toctree::
6+
:glob:
7+
8+
r/**
9+
```

website/docs/toc.html.markdown

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
# terraform-provider-libvirt Documentation
3+
4+
```eval_rst
5+
.. toctree::
6+
index
7+
```
8+
9+
```eval_rst
10+
.. toctree::
11+
:maxdepth: 2
12+
13+
resources
14+
```

0 commit comments

Comments
 (0)