Skip to content

Commit 617e5f5

Browse files
authored
Merge pull request kubernetes-client#2013 from tomplus/feat/update-doc
[doc] update Sphinx configuration
2 parents c9e2342 + 299a678 commit 617e5f5

12 files changed

+24
-4961
lines changed

.gitignore

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

doc/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source/README.md
2+
source/CONTRIBUTING.md
3+
source/kubernetes.*
4+
build

doc/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33

44
# You can set these variables from the command line.
5+
SPHINXAPIDOC = sphinx-apidoc
56
SPHINXOPTS = -c source
67
SPHINXBUILD = sphinx-build
78
SPHINXPROJ = kubernetes-python
@@ -17,5 +18,6 @@ help:
1718
# Catch-all target: route all unknown targets to Sphinx using the new
1819
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1920
html:
21+
$(SPHINXAPIDOC) -o "$(SOURCEDIR)" ../kubernetes/ -e -f
2022
$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2123
@echo "\nDocs rendered successfully, open _/build/html/index.html to view"

doc/source/README.md

Lines changed: 0 additions & 209 deletions
This file was deleted.

doc/source/conf.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,31 @@
1414

1515
import os
1616
import re
17-
import shutil
1817
import sys
1918

2019
from recommonmark.transform import AutoStructify
2120

22-
# Work around https://github.com/readthedocs/recommonmark/issues/152
23-
new_readme = []
21+
# --
22+
# Copy README.md, CONTRIBUTING.md to source/ directory and replace
23+
# all paths to point github files.
24+
def _copy_with_converting_link_to_repo(filename, new_filename):
25+
base_url = 'https://github.com/kubernetes-client/python/blob/master/'
2426

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)
27+
def subf(subs):
28+
label, url = subs.groups()
29+
if not url.startswith('http://') and not url.startswith('https://'):
30+
url = base_url + url
31+
return label + '(' + url + ')'
3032

31-
with open("README.md", "w") as n:
32-
n.writelines(new_readme)
33+
with open(filename, "r") as r:
34+
data = re.sub("(\[[^\]]+\])\(([^\)]+)\)", subf, r.read())
3335

34-
# apparently index.rst can't search for markdown not in the same directory
35-
shutil.copy("../../CONTRIBUTING.md", ".")
36+
with open(new_filename, "w") as w:
37+
w.write(data)
38+
39+
_copy_with_converting_link_to_repo("../../README.md", "README.md")
40+
_copy_with_converting_link_to_repo("../../CONTRIBUTING.md", "CONTRIBUTING.md")
41+
# --
3642

3743
sys.path.insert(0, os.path.abspath('../..'))
3844
# -- General configuration ----------------------------------------------------

0 commit comments

Comments
 (0)