Skip to content

Commit

Permalink
Merge pull request #2013 from tomplus/feat/update-doc
Browse files Browse the repository at this point in the history
[doc] update Sphinx configuration
  • Loading branch information
k8s-ci-robot committed Feb 27, 2023
2 parents c9e2342 + 299a678 commit 617e5f5
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 4,961 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,3 @@ target/
.idea/*
*.iml
.vscode

# created by sphinx documentation build
doc/source/README.md
doc/_build
4 changes: 4 additions & 0 deletions doc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source/README.md
source/CONTRIBUTING.md
source/kubernetes.*
build
2 changes: 2 additions & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#

# You can set these variables from the command line.
SPHINXAPIDOC = sphinx-apidoc
SPHINXOPTS = -c source
SPHINXBUILD = sphinx-build
SPHINXPROJ = kubernetes-python
Expand All @@ -17,5 +18,6 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
html:
$(SPHINXAPIDOC) -o "$(SOURCEDIR)" ../kubernetes/ -e -f
$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@echo "\nDocs rendered successfully, open _/build/html/index.html to view"
209 changes: 0 additions & 209 deletions doc/source/README.md

This file was deleted.

30 changes: 18 additions & 12 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,31 @@

import os
import re
import shutil
import sys

from recommonmark.transform import AutoStructify

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

with open("../../README.md", "r") as r:
lines = r.readlines()
for l in lines:
nl = re.sub("\[!\[[\w\s]+\]\(", "[![](", l)
new_readme.append(nl)
def subf(subs):
label, url = subs.groups()
if not url.startswith('http://') and not url.startswith('https://'):
url = base_url + url
return label + '(' + url + ')'

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

# apparently index.rst can't search for markdown not in the same directory
shutil.copy("../../CONTRIBUTING.md", ".")
with open(new_filename, "w") as w:
w.write(data)

_copy_with_converting_link_to_repo("../../README.md", "README.md")
_copy_with_converting_link_to_repo("../../CONTRIBUTING.md", "CONTRIBUTING.md")
# --

sys.path.insert(0, os.path.abspath('../..'))
# -- General configuration ----------------------------------------------------
Expand Down
Loading

0 comments on commit 617e5f5

Please sign in to comment.