From e1d1df9533c38fd0242d656fc62e4f67002929cf Mon Sep 17 00:00:00 2001 From: Philipp A Date: Mon, 5 Jun 2023 14:10:55 +0200 Subject: [PATCH 1/8] Add opengraph support --- {{cookiecutter.project_name}}/docs/conf.py | 5 +++++ {{cookiecutter.project_name}}/pyproject.toml | 1 + 2 files changed, 6 insertions(+) diff --git a/{{cookiecutter.project_name}}/docs/conf.py b/{{cookiecutter.project_name}}/docs/conf.py index 3b6bb229..62b2b83f 100644 --- a/{{cookiecutter.project_name}}/docs/conf.py +++ b/{{cookiecutter.project_name}}/docs/conf.py @@ -29,6 +29,10 @@ # The full version, including alpha/beta/rc tags release = info["Version"] +# Opengraph information: https://sphinxext-opengraph.readthedocs.io/ +ogp_site_url = "https://{{ cookiecutter.project_name }}.readthedocs.io/" +ogp_enable_meta_description = True + bibtex_bibfiles = ["references.bib"] templates_path = ["_templates"] nitpicky = True # Warn about broken links @@ -57,6 +61,7 @@ "sphinx_autodoc_typehints", "sphinx.ext.mathjax", "IPython.sphinxext.ipython_console_highlighting", + "sphinxext.opengraph", *[p.stem for p in (HERE / "extensions").glob("*.py")], ] diff --git a/{{cookiecutter.project_name}}/pyproject.toml b/{{cookiecutter.project_name}}/pyproject.toml index 8a7cde38..32c3109b 100644 --- a/{{cookiecutter.project_name}}/pyproject.toml +++ b/{{cookiecutter.project_name}}/pyproject.toml @@ -36,6 +36,7 @@ doc = [ "myst-nb", "sphinxcontrib-bibtex>=1.0.0", "sphinx-autodoc-typehints", + "sphinxext-opengraph", # For notebooks "ipykernel", "ipython", From 7df7c4a199f99e504184e13545ae83de69ccf70c Mon Sep 17 00:00:00 2001 From: Philipp A Date: Mon, 5 Jun 2023 14:12:57 +0200 Subject: [PATCH 2/8] dedupe --- {{cookiecutter.project_name}}/docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_name}}/docs/conf.py b/{{cookiecutter.project_name}}/docs/conf.py index 62b2b83f..83362ea2 100644 --- a/{{cookiecutter.project_name}}/docs/conf.py +++ b/{{cookiecutter.project_name}}/docs/conf.py @@ -30,7 +30,7 @@ release = info["Version"] # Opengraph information: https://sphinxext-opengraph.readthedocs.io/ -ogp_site_url = "https://{{ cookiecutter.project_name }}.readthedocs.io/" +ogp_site_url = urls["Documentation"] ogp_enable_meta_description = True bibtex_bibfiles = ["references.bib"] From a08e017ed02f96d04bf3fe5dc6b2f5b3872e36d2 Mon Sep 17 00:00:00 2001 From: Philipp A Date: Mon, 5 Jun 2023 14:23:24 +0200 Subject: [PATCH 3/8] Actually no config should be necessary --- {{cookiecutter.project_name}}/docs/conf.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/{{cookiecutter.project_name}}/docs/conf.py b/{{cookiecutter.project_name}}/docs/conf.py index 83362ea2..b7d1edfb 100644 --- a/{{cookiecutter.project_name}}/docs/conf.py +++ b/{{cookiecutter.project_name}}/docs/conf.py @@ -29,10 +29,6 @@ # The full version, including alpha/beta/rc tags release = info["Version"] -# Opengraph information: https://sphinxext-opengraph.readthedocs.io/ -ogp_site_url = urls["Documentation"] -ogp_enable_meta_description = True - bibtex_bibfiles = ["references.bib"] templates_path = ["_templates"] nitpicky = True # Warn about broken links From b4b78b5bbe2dba81645ca5564c3bec7338ebdd1f Mon Sep 17 00:00:00 2001 From: Philipp A Date: Mon, 5 Jun 2023 14:44:53 +0200 Subject: [PATCH 4/8] add social card image path --- {{cookiecutter.project_name}}/docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_name}}/docs/conf.py b/{{cookiecutter.project_name}}/docs/conf.py index b7d1edfb..6095604e 100644 --- a/{{cookiecutter.project_name}}/docs/conf.py +++ b/{{cookiecutter.project_name}}/docs/conf.py @@ -108,7 +108,7 @@ # a list of builtin themes. # html_theme = "sphinx_book_theme" -html_static_path = ["_static"] +html_static_path = ["_static", "_images"] html_title = project_name html_theme_options = { From b354ef07071d5303fba065d8937ac89e76e6a806 Mon Sep 17 00:00:00 2001 From: Philipp A Date: Mon, 5 Jun 2023 15:05:40 +0200 Subject: [PATCH 5/8] debug code --- {{cookiecutter.project_name}}/docs/conf.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.project_name}}/docs/conf.py b/{{cookiecutter.project_name}}/docs/conf.py index 6095604e..572cb74a 100644 --- a/{{cookiecutter.project_name}}/docs/conf.py +++ b/{{cookiecutter.project_name}}/docs/conf.py @@ -108,7 +108,7 @@ # a list of builtin themes. # html_theme = "sphinx_book_theme" -html_static_path = ["_static", "_images"] +html_static_path = ["_static"] html_title = project_name html_theme_options = { @@ -139,3 +139,8 @@ def setup(app): }, True, ) + + # TEMP + from subcommand import run + + app.connect("build-finished", lambda app, exc: run(["tree", app.outdir])) From 6f9d0e4d2b0cbd0d93a5677b5a3ec92d20a6046b Mon Sep 17 00:00:00 2001 From: Philipp A Date: Mon, 5 Jun 2023 15:10:40 +0200 Subject: [PATCH 6/8] oops --- {{cookiecutter.project_name}}/docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_name}}/docs/conf.py b/{{cookiecutter.project_name}}/docs/conf.py index 572cb74a..c509d49e 100644 --- a/{{cookiecutter.project_name}}/docs/conf.py +++ b/{{cookiecutter.project_name}}/docs/conf.py @@ -141,6 +141,6 @@ def setup(app): ) # TEMP - from subcommand import run + from subprocess import run app.connect("build-finished", lambda app, exc: run(["tree", app.outdir])) From 59542a804d27f525751f42f0d8343519b4ec2bdf Mon Sep 17 00:00:00 2001 From: Philipp A Date: Mon, 5 Jun 2023 15:20:17 +0200 Subject: [PATCH 7/8] no tree --- {{cookiecutter.project_name}}/docs/conf.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/{{cookiecutter.project_name}}/docs/conf.py b/{{cookiecutter.project_name}}/docs/conf.py index c509d49e..1ec4d4f1 100644 --- a/{{cookiecutter.project_name}}/docs/conf.py +++ b/{{cookiecutter.project_name}}/docs/conf.py @@ -141,6 +141,4 @@ def setup(app): ) # TEMP - from subprocess import run - - app.connect("build-finished", lambda app, exc: run(["tree", app.outdir])) + app.connect("build-finished", lambda app, exc: print(*sorted(Path(app.outdir).glob("**/*")), sep="\n")) From 7ef6174d94255cbe54b0f8e2d7d4813e1ee33528 Mon Sep 17 00:00:00 2001 From: Philipp A Date: Mon, 5 Jun 2023 15:38:24 +0200 Subject: [PATCH 8/8] remove temp code --- {{cookiecutter.project_name}}/docs/conf.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/{{cookiecutter.project_name}}/docs/conf.py b/{{cookiecutter.project_name}}/docs/conf.py index 1ec4d4f1..b7d1edfb 100644 --- a/{{cookiecutter.project_name}}/docs/conf.py +++ b/{{cookiecutter.project_name}}/docs/conf.py @@ -139,6 +139,3 @@ def setup(app): }, True, ) - - # TEMP - app.connect("build-finished", lambda app, exc: print(*sorted(Path(app.outdir).glob("**/*")), sep="\n"))