From 4e730120eeef8238e670d34dc6039c91e25aaf81 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 5 Apr 2020 16:50:52 +0200 Subject: [PATCH] Make the quick target more readable --- docs/Makefile | 12 ++++++------ docs/source/conf.py | 35 ++++++++++++++++++++++++++++------- docs/source/index.md | 3 +++ docs/source/index.rst | 20 -------------------- 4 files changed, 37 insertions(+), 33 deletions(-) delete mode 100644 docs/source/index.rst diff --git a/docs/Makefile b/docs/Makefile index 1298b162e9..cb74ed14a9 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -3,7 +3,7 @@ # You can set these variables from the command line, and also # from the environment for the first two. -SPHINXOPTS ?= +SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build SPHINXMULTIVERSION ?= sphinx-multiversion SPHINXAPIDOC ?= sphinx-apidoc @@ -40,7 +40,7 @@ help: # Evennia - custom commands -# helper targets +# helper targets _check-env: @EVDIR=$(EVDIR) EVGAMEDIR=$(EVGAMEDIR) bash -e checkenv.sh @@ -59,7 +59,7 @@ _build: @EVDIR=$(EVDIR) EVGAMEDIR=$(EVGAMEDIR) $(SPHINXBUILD) $(SPHINXOPTS) "$(SOURCEDIR)" "$(BUILDDIR)/html" _quick-build: - NOAUTODOC=1 EVDIR=$(EVDIR) EVGAMEDIR=$(EVGAMEDIR) $(SPHINXBUILD) $(SPHINXOPTS) "$(SOURCEDIR)" "$(BUILDDIR)/html" $(QUICKFILES) + @NOAUTODOC=1 EVDIR=$(EVDIR) EVGAMEDIR=$(EVGAMEDIR) $(SPHINXBUILD) $(SPHINXOPTS) "$(SOURCEDIR)" "$(BUILDDIR)/html" $(QUICKFILES) _multiversion-build: @EVDIR=$(EVDIR) EVGAMEDIR=$(EVGAMEDIR) $(SPHINXMULTIVERSION) $(SPHINXOPTS) "$(SOURCEDIR)" "$(BUILDDIR)/html" $(SPHINXOPTS) @@ -67,7 +67,7 @@ _multiversion-build: _multiversion-deploy: @bash -e deploy.sh -# main targets +# main targets install: @pip install -r requirements.txt @@ -83,9 +83,9 @@ quick: @echo "" @echo "Documentation built (no autodocs). \nTo see result, open evennia/docs/build/html/index.html in a browser." -local: +local: make _check-env - make clean + make clean make _autodoc-index make _build @echo "" diff --git a/docs/source/conf.py b/docs/source/conf.py index 5ac688b4fb..8a1f04769a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -55,13 +55,10 @@ release = '0.9' extensions = [ "recommonmark", "sphinx_multiversion", + "sphinx.ext.napoleon", "sphinx.ext.autosectionlabel" ] -if not os.environ.get("NOAUTODOC"): - extensions.append("sphinx.ext.napoleon") - - # make sure sectionlabel references can be used as path/to/file:heading autosectionlabel_prefix_document = True @@ -74,6 +71,8 @@ templates_path = ['_templates'] exclude_patterns = [] + + # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for @@ -102,12 +101,34 @@ smv_outputdir_format = "versions" + sep + "{config.release}" # dynamic setup -github_doc_root = "https://github.com/evennia/tree/master/docs" +github_code_root = "https://github.com/evennia/tree/master/" +github_doc_root = "https://github.com/evennia/tree/master/docs/sources/" + +def url_resolver(url): + print(f"in url_resolver: {url}") + if url.startswith("github:"): + return github_code_root + url[7:] + else: + return github_doc_root + url + + +_NO_AUTODOC = os.environ.get("NOAUTODOC") + +def autodoc_skip_member(app, what, name, obj, skip, options): + if _NO_AUTODOC: + return True + return False + + +if _NO_AUTODOC: + exclude_patterns = ["api/*"] + def setup(app): - # recommonmark setup + app.connect("autodoc-skip-member", autodoc_skip_member) + app.add_config_value('recommonmark_config', { - 'url_resolver': lambda url: github_doc_root + url, + 'url_resolver': url_resolver, 'auto_toc_tree_section': 'Contents', }, True) app.add_transform(AutoStructify) diff --git a/docs/source/index.md b/docs/source/index.md index 85424ac477..a807d9c5b8 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -3,6 +3,9 @@ Evennia documentation master file, created by # Welcome to Evennia's documentation! +Click [here](../evennia/objects/objects.py) to go to objects.py ... .. +Another [link](github:objects/objects.py) to click ... + ## Indices and tables * [genindex](genindex) diff --git a/docs/source/index.rst b/docs/source/index.rst deleted file mode 100644 index afd5a1e7ad..0000000000 --- a/docs/source/index.rst +++ /dev/null @@ -1,20 +0,0 @@ -.. Evennia documentation master file, created by - sphinx-quickstart on Sat Apr 4 23:52:36 2020. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to Evennia's documentation! -=================================== - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search`