Skip to content

Commit 3b84216

Browse files
committed
Mulitple docs fixes
* Document how to build the doumentation with sphinx For convinience, I added a Makefile which spares one to memorize the long sphinx command, or type python setup.py build_sphinx You simply use `make html` and you will get the docs. * Render README with markdown properly conf.py includes some code to work around a bug in common mark. The markdown is now properly converted to HTML. * Fix rendering of CONTRIBUTING.md
1 parent 4a204fa commit 3b84216

10 files changed

+71
-20
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,7 @@ target/
6767
.idea/*
6868
*.iml
6969
.vscode
70+
71+
# created by sphinx documentation build
72+
doc/source/README.md
73+
doc/_build

doc/Makefile

+21
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.
5+
SPHINXOPTS = -c source
6+
SPHINXBUILD = sphinx-build
7+
SPHINXPROJ = kubernetes-python
8+
SOURCEDIR = source
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+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
html:
20+
$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21+
@echo "\nDocs rendered successfully, open _/build/html/index.html to view"

doc/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Building the documentation
2+
==========================
3+
4+
Install the test requirements with:
5+
6+
```
7+
$ pip install -r ../test-requirements.txt
8+
```
9+
10+
Use `make html` to build the docs in html format.
11+

doc/requirements-docs.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
recommonmark
2+
sphinx_markdown_tables

doc/source/conf.py

+27-5
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,37 @@
1313
# limitations under the License.
1414

1515
import os
16+
import re
17+
import shutil
1618
import sys
1719

18-
from recommonmark.parser import CommonMarkParser
20+
from recommonmark.transform import AutoStructify
21+
22+
# Work around https://github.com/readthedocs/recommonmark/issues/152
23+
new_readme = []
24+
25+
with open("../../README.md", "r") as r:
26+
lines = r.readlines()
27+
for l in lines:
28+
nl = re.sub("\[!\[[\w\s]+\]\(", "[![](", l)
29+
new_readme.append(nl)
30+
31+
with open("README.md", "w") as n:
32+
n.writelines(new_readme)
33+
34+
# apparently index.rst can't search for markdown not in the same directory
35+
shutil.copy("../../CONTRIBUTING.md", ".")
1936

2037
sys.path.insert(0, os.path.abspath('../..'))
2138
# -- General configuration ----------------------------------------------------
2239

23-
source_parsers = {
24-
'.md': CommonMarkParser,
25-
}
26-
2740
source_suffix = ['.rst', '.md']
2841

2942
# Add any Sphinx extension module names here, as strings. They can be
3043
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
3144
extensions = [
45+
'sphinx_markdown_tables',
46+
'recommonmark',
3247
'sphinx.ext.autodoc',
3348
#'sphinx.ext.intersphinx',
3449
]
@@ -80,3 +95,10 @@
8095

8196
# Example configuration for intersphinx: refer to the Python standard library.
8297
#intersphinx_mapping = {'http://docs.python.org/': None}
98+
def setup(app):
99+
app.add_config_value('recommonmark_config', {
100+
'auto_toc_tree_section': 'Contents',
101+
'enable_eval_rst': True,
102+
}, True)
103+
app.add_transform(AutoStructify)
104+

doc/source/contributing.rst

-4
This file was deleted.

doc/source/index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ Contents:
1111
.. toctree::
1212
:maxdepth: 2
1313

14-
readme
14+
README <README.md>
1515
installation
1616
usage
1717
modules
18-
contributing
18+
contributing <CONTRIBUTING.md>
1919

2020
Indices and tables
2121
==================

doc/source/readme.rst

-4
This file was deleted.

setup.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@
6262
'kubernetes.stream', 'kubernetes.client.models',
6363
'kubernetes.utils'],
6464
include_package_data=True,
65-
long_description="""\
66-
Python client for kubernetes http://kubernetes.io/
67-
""",
65+
long_description="Python client for kubernetes http://kubernetes.io/",
6866
classifiers=[
6967
"Development Status :: %s" % DEVELOPMENT_STATUS,
7068
"Topic :: Utilities",

test-requirements.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ pluggy>=0.3.1
55
py>=1.4.31
66
randomize>=0.13
77
mock>=2.0.0
8-
sphinx>=1.2.1,!=1.3b1,<1.4 # BSD
8+
sphinx>=1.4 # BSD
99
recommonmark
10+
sphinx_markdown_tables
1011
codecov>=1.4.0
1112
pycodestyle
1213
autopep8
13-
isort
14+
isort

0 commit comments

Comments
 (0)