Skip to content

Commit

Permalink
Fix link to tag pages
Browse files Browse the repository at this point in the history
  • Loading branch information
melissawm committed Sep 1, 2022
1 parent 83b7703 commit 409b9b1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
3 changes: 3 additions & 0 deletions RELEASE.md → docs/details/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ documentation.
configuration
examples.md
devel
details/RELEASE.md

.. toctree::
:caption: Site tags
Expand Down
29 changes: 12 additions & 17 deletions src/sphinx_tags/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from docutils import nodes
from pathlib import Path

__version__ = "0.1.3"
__version__ = "0.1.3dev"

logger = getLogger("sphinx-tags")

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 409b9b1

Please sign in to comment.