Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[doc] update Sphinx configuration #2013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.*
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed "kubernetes.*.rst" files, there are generated by sphinx-apidoc during building process.

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