From 698125affd8ae20a4e47b09e998acf9e1d4cf0e2 Mon Sep 17 00:00:00 2001 From: Romain Bezut Date: Sun, 29 Sep 2024 03:20:48 +0200 Subject: [PATCH] docs: social cards and broken link fixes. Signed-off-by: Romain Bezut --- README.rst | 4 ++-- docs/conf.py | 15 ++++++++++----- docs/requirements.txt | 3 ++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index 01cba12..4ae3492 100644 --- a/README.rst +++ b/README.rst @@ -94,8 +94,8 @@ Participants must uphold the `code of conduct`_. .. _issue: https://github.com/morian/aio-ld2410/issues/new .. _pull request: https://github.com/morian/aio-ld2410/compare/ .. _start a discussion: https://github.com/morian/aio-ld2410/discussions -.. _code of conduct: https://github.com/python-websockets/websockets/blob/main/CODE_OF_CONDUCT.md +.. _code of conduct: https://github.com/morian/aio-ld2410/blob/master/CODE_OF_CONDUCT.md ``aio-ld2410`` is released under the `MIT license`_. -.. _MIT license: https://github.com/morian/aio-ld2410/blob/main/LICENSE +.. _MIT license: https://github.com/morian/aio-ld2410/blob/master/LICENSE diff --git a/docs/conf.py b/docs/conf.py index dff6ed5..6339bd4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -33,6 +33,7 @@ 'sphinx_copybutton', 'sphinx_inline_tabs', 'sphinx_autodoc_typehints', + 'sphinxext.opengraph', ] templates_path = ['_templates'] @@ -80,8 +81,10 @@ # Define the canonical URL if you are using a custom domain on Read the Docs html_baseurl = os.environ.get('READTHEDOCS_CANONICAL_URL', '') +ogp_site_url = 'https://aio-ld2410.readthedocs.io/en/latest/' + # Tell Jinja2 templates the build is running on Read the Docs -if os.environ.get('READTHEDOCS') == 'True' or True: +if os.environ.get('READTHEDOCS') == 'True': if 'html_context' not in globals(): html_context = {} @@ -114,7 +117,8 @@ def get_current_commit() -> str: commit = get_current_commit() -code_url = f'https://github.com/morian/aio-ld2410/blob/{commit}' +# branch = get_current_branch() +repo_url = 'https://github.com/morian/aio-ld2410/' def linkcode_resolve(domain, info): @@ -148,7 +152,7 @@ def linkcode_resolve(domain, info): return None start, end = lines[1], lines[1] + len(lines[0]) - 1 - return f'{code_url}/{file}#L{start}-L{end}' + return f'{repo_url}/blob/{commit}/{file}#L{start}-L{end}' # -- Options for HTML output ------------------------------------------------- @@ -157,8 +161,8 @@ def linkcode_resolve(domain, info): html_theme = 'furo' html_theme_options = { - 'source_repository': 'https://github.com/morian/aio-ld2410/', - 'source_branch': 'master', + 'source_repository': repo_url, + 'source_branch': commit, 'source_directory': 'docs/', 'light_css_variables': { 'color-brand-primary': '#306998', # blue from logo @@ -169,6 +173,7 @@ def linkcode_resolve(domain, info): 'color-brand-content': '#ffd43bd9', # yellow from logo, transparent like text }, 'sidebar_hide_name': True, + 'top_of_page_buttons': ['view'], } # Add any paths that contain custom static files (such as style sheets) here, diff --git a/docs/requirements.txt b/docs/requirements.txt index e987ed1..a9cbea0 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,6 +1,7 @@ furo==2024.8.6 sphinx==8.0.2 sphinx_autodoc_typehints==2.4.4 -sphinx_inline_tabs==2023.4.21 sphinx_copybutton==0.5.2 +sphinx_inline_tabs==2023.4.21 +sphinxext_opengraph==0.9.1 typing_extensions==4.12.2