Skip to content
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

[docs] Fix wrong links in docs #469

Merged
merged 1 commit into from
Mar 27, 2021
Merged
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
27 changes: 20 additions & 7 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,35 @@
import shutil
import builtins
import asteroid_sphinx_theme

import codecs
import os
import re

PATH_HERE = os.path.abspath(os.path.dirname(__file__))
PATH_ROOT = os.path.join(PATH_HERE, "..", "..")
sys.path.insert(0, os.path.abspath(PATH_ROOT))


def read(*parts):
with codecs.open(os.path.join(PATH_ROOT, *parts), "r") as fp:
return fp.read()


def find_version(*file_paths):
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")


# -- Project information -----------------------------------------------------

project = "asteroid"
copyright = "2019, Oncoming"
author = "Manuel Pariente et al."
# The short X.Y version
version = "0.4.0"
# The full version, including alpha/beta/rc tags
release = "0.4.0rc1"
release = find_version("asteroid", "__init__.py")

# -- General configuration ---------------------------------------------------

Expand Down Expand Up @@ -109,7 +123,6 @@
# Resolve function for the linkcode extension. Now, the source button links
# to the Github code instead of code in the docs.
def linkcode_resolve(domain, info):
# TODO: handle the release better. Maybe use the versioneer?
if domain != "py" or not info["module"]:
return None
info["module"] = info["module"].replace("asteroid.filterbanks", "asteroid_filterbanks")
Expand Down Expand Up @@ -143,7 +156,8 @@ def find_source():
file, start, end = find_source()
except:
return base_url % str_from(filename, start=repos_name)
return base_url % str_from(file, start=repos_name) + "#L%d-L%d" % (start, end)
out = base_url % str_from(file, start=repos_name) + "#L%d-L%d" % (start, end)
return out.replace("asteroid/asteroid/asteroid/", "asteroid")


# -- Options for HTML output -------------------------------------------------
Expand All @@ -167,7 +181,6 @@ def find_source():
"collapse_navigation": False,
"display_version": True,
"logo_only": False,
"asteroid_project": "docs",
}

html_logo = "_static/images/favicon.ico"
Expand Down