From 409b9b134076d4313612f4a81c2636f8158aa446 Mon Sep 17 00:00:00 2001 From: melissawm Date: Thu, 1 Sep 2022 19:21:07 -0300 Subject: [PATCH] Fix link to tag pages --- RELEASE.md => docs/details/RELEASE.md | 3 +++ docs/index.rst | 1 + src/sphinx_tags/__init__.py | 29 +++++++++++---------------- 3 files changed, 16 insertions(+), 17 deletions(-) rename RELEASE.md => docs/details/RELEASE.md (94%) diff --git a/RELEASE.md b/docs/details/RELEASE.md similarity index 94% rename from RELEASE.md rename to docs/details/RELEASE.md index 9d6eb17..44cbf66 100644 --- a/RELEASE.md +++ b/docs/details/RELEASE.md @@ -2,6 +2,9 @@ `sphinx-tags` uses [flit](https://github.com/pypa/flit) to manage releases. +```{tags} development +``` + To cut a new release: 1. Make sure the version string in `src/sphinx_tags/__init__.py` is updated with diff --git a/docs/index.rst b/docs/index.rst index 2a848bc..bf2a288 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -17,6 +17,7 @@ documentation. configuration examples.md devel + details/RELEASE.md .. toctree:: :caption: Site tags diff --git a/src/sphinx_tags/__init__.py b/src/sphinx_tags/__init__.py index 8bde402..27e8b9c 100644 --- a/src/sphinx_tags/__init__.py +++ b/src/sphinx_tags/__init__.py @@ -7,7 +7,7 @@ from docutils import nodes from pathlib import Path -__version__ = "0.1.3" +__version__ = "0.1.3dev" logger = getLogger("sphinx-tags") @@ -38,22 +38,17 @@ def run(self): count = 0 for tag in tags: count += 1 - on_rtd = os.environ.get("READTHEDOCS") == "True" - if on_rtd: - link = os.path.join(self.env.app.config.tags_output_dir, f"{tag}.html") - else: - link = os.path.join( - self.env.app.srcdir, - self.env.app.outdir, - self.env.app.config.tags_output_dir, - f"{tag}.html", - ) - # link = os.path.join( - # self.env.app.srcdir, - # self.env.app.outdir, - # self.env.app.config.tags_output_dir, - # f"{tag}.html", - # ) + # We want the link to be the path to the _tags folder, relative to this document's path + # where + # + # - self.env.app.config.tags_output_dir + # | + # - subfolder + # | + # - current_doc_path + docpath = Path(self.env.doc2path(self.env.docname)).parent + rootdir = os.path.relpath(self.env.app.config.tags_output_dir, docpath) + link = os.path.join(rootdir, f"{tag}.html") tag_node = nodes.reference(refuri=link, text=tag) result += tag_node if not count == len(tags):