Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-sphinxext-opengraph for openSUSE:Factory checked in at 2022-11-01 13:42:07
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-sphinxext-opengraph (Old)
and /work/SRC/openSUSE:Factory/.python-sphinxext-opengraph.new.2275 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-sphinxext-opengraph"
Tue Nov 1 13:42:07 2022 rev:2 rq:1032480 version:0.6.3
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-sphinxext-opengraph/python-sphinxext-opengraph.changes 2021-09-17 23:26:28.793264449 +0200
+++ /work/SRC/openSUSE:Factory/.python-sphinxext-opengraph.new.2275/python-sphinxext-opengraph.changes 2022-11-01 13:42:16.455802253 +0100
@@ -1,0 +2,24 @@
+Tue Oct 11 15:31:19 UTC 2022 - Yogalakshmi Arunachalam
+
+- Update to version 0.6.3
+ Fix first_image not resolving correctly when in subdirectories and ogp_image is defined. by @ItayZiv in #63
+
+- Update to version 0.6.2
+ chore(README) Typo fix by @tony in #58
+ Fix first_image not resolving correctly in subdirectories by @ItayZiv in #61
+
+- Update to version 0.6.1
+ fix og:url for "dirhtml" builder by @ru-fu in #54
+
+- Update to version 0.6.0
+ Include license in setup.py by @sciencewhiz in #52
+ Add per-file overrides using field lists by @ItayZiv in #50
+
+- Update to version 0.5.1
+ Escape quotations in Open Graph description when smart quotes are disabled. by @ItayZiv in #49
+
+- Update to version 0.5.0
+ Skipping code blocks and fixing docs build. by @Robpol86 in #47
+ Convert relative paths to absolute in og:image. by @Robpol86 in #48
+
+-------------------------------------------------------------------
Old:
----
sphinxext-opengraph-0.4.2.tar.gz
New:
----
sphinxext-opengraph-0.6.3.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-sphinxext-opengraph.spec ++++++
--- /var/tmp/diff_new_pack.6rHcGy/_old 2022-11-01 13:42:16.995805126 +0100
+++ /var/tmp/diff_new_pack.6rHcGy/_new 2022-11-01 13:42:16.999805147 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-sphinxext-opengraph
#
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -27,7 +27,7 @@
%endif
%define skip_python2 1
Name: python-sphinxext-opengraph
-Version: 0.4.2
+Version: 0.6.3
Release: 0
Summary: Sphinx Extension to enable OGP support
License: MIT
++++++ sphinxext-opengraph-0.4.2.tar.gz -> sphinxext-opengraph-0.6.3.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/README.md new/sphinxext-opengraph-0.6.3/README.md
--- old/sphinxext-opengraph-0.4.2/README.md 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/README.md 2022-03-29 19:45:08.000000000 +0200
@@ -28,7 +28,7 @@
* `ogp_site_name`
* This is not required. Name of the site. This is displayed above the title.
* `ogp_image`
- * This is not required. Link to image to show.
+ * This is not required. Link to image to show. Note that all relative paths are converted to be relative to the root of the html output as defined by `ogp_site_name`.
* `ogp_image_alt`
* This is not required. Alt text for image. Defaults to using `ogp_site_name` or the document's title as alt text, if available. Set to `False` if you want to turn off alt text completely.
* `ogp_use_first_image`
@@ -37,7 +37,7 @@
* This sets the ogp type attribute, for more information on the types available please take a look at https://ogp.me/#types. By default it is set to `website`, which should be fine for most use cases.
* `ogp_custom_meta_tags`
* This is not required. List of custom html snippets to insert.
-
+
## Example Config
### Simple Config
@@ -60,3 +60,48 @@
]
```
+
+## Per Page Overrides
+[Field lists](https://www.sphinx-doc.org/en/master/usage/restructuredtext/field-lists.html) are used to allow you to override certain settings on each page and set unsupported arbitrary OpenGraph tags.
+
+Make sure you place the fields at the very start of the document such that Sphinx will pick them up and also won't build them into the html.
+
+### Overrides
+These are some overrides that can be used, you can actually override any tag and field lists will always take priority.
+
+* `:og_description_length:`
+ * Configure the amount of characters to grab for the description of the page. If the value isn't a number it will fall back to `ogp_description_length`. Note the slightly different syntax because this isn't directly an OpenGraph tag.
+* `:og:description:`
+ * Lets you override the description of the page.
+* `:og:title:`
+ * Lets you override the title of the page.
+* `:og:type:`
+ * Override the type of the page, for the list of available types take a look at https://ogp.me/#types.
+* `:ogp:image:`
+ * Set the image for the page.[^1]
+* `:ogp:image:alt:`
+ * Sets the alt text. Will be ignored if there is no image set.
+
+### Example
+Remember that the fields **must** be placed at the very start of the file. You can verify Sphinx has picked up the fields if they aren't shown in the final html file.
+
+```rst
+:og:description: New description
+:og:image: http://example.org/image.png
+:og:image:alt: Example Image
+
+Page contents
+=============
+```
+
+### Arbitrary Tags[^1]
+Additionally, you can use field lists to add any arbitrary OpenGraph tag not supported by the extension. The syntax for arbitrary tags is the same with `:og:tag: content`. For Example:
+
+```rst
+:og:video: http://example.org/video.mp4
+
+Page contents
+=============
+```
+
+[^1]: Note: Relative file paths for images, videos and audio are currently **not** supported when using field lists. Please use an absolute path instead.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/docs/requirements.txt new/sphinxext-opengraph-0.6.3/docs/requirements.txt
--- old/sphinxext-opengraph-0.4.2/docs/requirements.txt 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/docs/requirements.txt 2022-03-29 19:45:08.000000000 +0200
@@ -1,4 +1,4 @@
-myst-parser==0.13.0
-furo==2020.12.30b24
-sphinx==3.4.0
+myst-parser==0.15.2
+furo==2021.11.12.1
+sphinx==4.2.0
./
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/setup.py new/sphinxext-opengraph-0.6.3/setup.py
--- old/sphinxext-opengraph-0.4.2/setup.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/setup.py 2022-03-29 19:45:08.000000000 +0200
@@ -28,6 +28,7 @@
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/wpilibsuite/sphinxext-opengraph",
+ license="LICENSE.md",
install_requires=["sphinx>=2.0"],
packages=["sphinxext/opengraph"],
classifiers=[
@@ -36,12 +37,13 @@
"Environment :: Web Environment",
"Framework :: Sphinx :: Extension",
"Intended Audience :: Developers",
- "License :: OSI Approved :: MIT License",
+ "License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
"Programming Language :: Python",
"Topic :: Documentation :: Sphinx",
"Topic :: Documentation",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/sphinxext/opengraph/__init__.py new/sphinxext-opengraph-0.6.3/sphinxext/opengraph/__init__.py
--- old/sphinxext-opengraph-0.4.2/sphinxext/opengraph/__init__.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/sphinxext/opengraph/__init__.py 2022-03-29 19:45:08.000000000 +0200
@@ -1,10 +1,9 @@
from typing import Any, Dict
from urllib.parse import urljoin, urlparse, urlunparse
-from pathlib import Path, PosixPath
+from pathlib import Path
import docutils.nodes as nodes
from sphinx.application import Sphinx
-from sphinx.util import logger
from .descriptionparser import get_description
from .titleparser import get_title
@@ -30,6 +29,8 @@
def make_tag(property: str, content: str) -> str:
+ # Parse quotation, so they won't break html tags if smart quotes are disabled
+ content = content.replace('"', """)
return f'<meta property="{property}" content="{content}" />\n '
@@ -39,10 +40,17 @@
doctree: nodes.document,
config: Dict[str, Any],
) -> str:
+ # Get field lists for per-page overrides
+ fields = context["meta"]
+ if fields is None:
+ fields = {}
+ tags = {}
# Set length of description
try:
- desc_len = int(config["ogp_description_length"])
+ desc_len = int(
+ fields.get("ogp_description_length", config["ogp_description_length"])
+ )
except ValueError:
desc_len = DEFAULT_DESCRIPTION_LENGTH
@@ -53,13 +61,12 @@
# Parse/walk doctree for metadata (tag/description)
description = get_description(doctree, desc_len, [title, title_excluding_html])
- tags = "\n "
-
# title tag
- tags += make_tag("og:title", title)
+ tags["og:title"] = title
# type tag
- tags += make_tag("og:type", config["ogp_type"])
+ tags["og:type"] = config["ogp_type"]
+
if os.getenv("READTHEDOCS") and config["ogp_site_url"] is None:
# readthedocs uses html_baseurl for sphinx > 1.8
parse_result = urlparse(config["html_baseurl"])
@@ -81,26 +88,38 @@
# url tag
# Get the URL of the specific page
- page_url = urljoin(
- config["ogp_site_url"], context["pagename"] + context["file_suffix"]
- )
- tags += make_tag("og:url", page_url)
+ if context["builder"] == "dirhtml":
+ page_url = urljoin(config["ogp_site_url"], context["pagename"] + "/")
+ else:
+ page_url = urljoin(
+ config["ogp_site_url"], context["pagename"] + context["file_suffix"]
+ )
+ tags["og:url"] = page_url
# site name tag
site_name = config["ogp_site_name"]
if site_name:
- tags += make_tag("og:site_name", site_name)
+ tags["og:site_name"] = site_name
# description tag
if description:
- tags += make_tag("og:description", description)
+ tags["og:description"] = description
# image tag
# Get basic values from config
- image_url = config["ogp_image"]
- ogp_use_first_image = config["ogp_use_first_image"]
- ogp_image_alt = config["ogp_image_alt"]
+ if "og:image" in fields:
+ image_url = fields["og:image"]
+ ogp_use_first_image = False
+ ogp_image_alt = fields.get("og:image:alt")
+ fields.pop("og:image", None)
+ else:
+ image_url = config["ogp_image"]
+ ogp_use_first_image = config["ogp_use_first_image"]
+ ogp_image_alt = fields.get("og:image:alt", config["ogp_image_alt"])
+
+ fields.pop("og:image:alt", None)
+ first_image = None
if ogp_use_first_image:
first_image = doctree.next_node(nodes.image)
if (
@@ -109,22 +128,39 @@
):
image_url = first_image["uri"]
ogp_image_alt = first_image.get("alt", None)
+ else:
+ first_image = None
if image_url:
- tags += make_tag("og:image", image_url)
+ # temporarily disable relative image paths with field lists
+ if "og:image" not in fields:
+ image_url_parsed = urlparse(image_url)
+ if not image_url_parsed.scheme:
+ # Relative image path detected, relative to the source. Make absolute.
+ if first_image:
+ root = page_url
+ else: # ogp_image is set
+ # ogp_image is defined as being relative to the site root.
+ # This workaround is to keep that functionality from breaking.
+ root = config["ogp_site_url"]
+
+ image_url = urljoin(root, image_url_parsed.path)
+ tags["og:image"] = image_url
# Add image alt text (either provided by config or from site_name)
if isinstance(ogp_image_alt, str):
- tags += make_tag("og:image:alt", ogp_image_alt)
+ tags["og:image:alt"] = ogp_image_alt
elif ogp_image_alt is None and site_name:
- tags += make_tag("og:image:alt", site_name)
+ tags["og:image:alt"] = site_name
elif ogp_image_alt is None and title:
- tags += make_tag("og:image:alt", title)
+ tags["og:image:alt"] = title
- # custom tags
- tags += "\n".join(config["ogp_custom_meta_tags"])
+ # arbitrary tags and overrides
+ tags.update({k: v for k, v in fields.items() if k.startswith("og:")})
- return tags
+ return "\n" + "\n".join(
+ [make_tag(p, c) for p, c in tags.items()] + config["ogp_custom_meta_tags"]
+ )
def html_page_context(
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/sphinxext/opengraph/descriptionparser.py new/sphinxext-opengraph-0.6.3/sphinxext/opengraph/descriptionparser.py
--- old/sphinxext-opengraph-0.4.2/sphinxext/opengraph/descriptionparser.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/sphinxext/opengraph/descriptionparser.py 2022-03-29 19:45:08.000000000 +0200
@@ -18,7 +18,7 @@
# Hack to prevent requirement for the doctree to be passed in.
# It's only used by doctree.walk(...) to print debug messages.
- if document == None:
+ if document is None:
class document_cls:
class reporter:
@@ -67,7 +67,7 @@
if node.astext() in self.known_titles:
raise nodes.SkipNode
- if isinstance(node, nodes.raw):
+ if isinstance(node, nodes.raw) or isinstance(node.parent, nodes.literal_block):
raise nodes.SkipNode
# Only include leaf nodes in the description
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/conftest.py new/sphinxext-opengraph-0.6.3/tests/conftest.py
--- old/sphinxext-opengraph-0.4.2/tests/conftest.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/conftest.py 2022-03-29 19:45:08.000000000 +0200
@@ -19,8 +19,11 @@
yield app
-def _meta_tags(content):
- c = (content.outdir / "index.html").read_text()
+def _meta_tags(content, subdir=None):
+ if subdir is None:
+ c = (content.outdir / "index.html").read_text()
+ else:
+ c = (content.outdir / subdir / "index.html").read_text()
return BeautifulSoup(c, "html.parser").find_all("meta")
@@ -42,5 +45,14 @@
]
+@pytest.fixture()
+def og_meta_tags_sub(content):
+ return [
+ tag
+ for tag in _meta_tags(content, "sub")
+ if tag.get("property", "").startswith("og:")
+ ]
+
+
def pytest_configure(config):
config.addinivalue_line("markers", "sphinx")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-arbitrary-tags/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-arbitrary-tags/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-arbitrary-tags/conf.py 1970-01-01 01:00:00.000000000 +0100
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-arbitrary-tags/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -0,0 +1,8 @@
+extensions = ["sphinxext.opengraph"]
+
+master_doc = "index"
+exclude_patterns = ["_build"]
+
+html_theme = "basic"
+
+ogp_site_url = "http://example.org/en/latest/"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-arbitrary-tags/index.rst new/sphinxext-opengraph-0.6.3/tests/roots/test-arbitrary-tags/index.rst
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-arbitrary-tags/index.rst 1970-01-01 01:00:00.000000000 +0100
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-arbitrary-tags/index.rst 2022-03-29 19:45:08.000000000 +0200
@@ -0,0 +1,4 @@
+:og:video: http://example.org/en/latest/video.mp4
+:og:video:type: video/mp4
+
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse at lorem ornare, fringilla massa nec, venenatis mi. Donec erat sapien, tincidunt nec rhoncus nec, scelerisque id diam. Orci varius natoque penatibus et magnis dis parturient mauris.
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-custom-tags/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-custom-tags/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-custom-tags/conf.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-custom-tags/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -5,7 +5,7 @@
html_theme = "basic"
-ogp_site_url = "http://example.org/"
+ogp_site_url = "http://example.org/en/latest/"
ogp_custom_meta_tags = [
'<meta property="og:ignore_canonical" content="true" />',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-description-length/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-description-length/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-description-length/conf.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-description-length/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -5,5 +5,5 @@
html_theme = "basic"
-ogp_site_url = "http://example.org/"
+ogp_site_url = "http://example.org/en/latest/"
ogp_description_length = 50
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-double-spacing/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-double-spacing/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-double-spacing/conf.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-double-spacing/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -5,4 +5,4 @@
html_theme = "basic"
-ogp_site_url = "http://example.org/"
+ogp_site_url = "http://example.org/en/latest/"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-first-image/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-first-image/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-first-image/conf.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-first-image/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -6,7 +6,7 @@
html_theme = "basic"
ogp_site_name = "Example's Docs!"
-ogp_site_url = "http://example.org/"
-ogp_image = "http://example.org/image33.png"
+ogp_site_url = "http://example.org/en/latest/"
+ogp_image = "http://example.org/en/latest/image33.png"
ogp_image_alt = "TEST"
ogp_use_first_image = True
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-first-image/index.rst new/sphinxext-opengraph-0.6.3/tests/roots/test-first-image/index.rst
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-first-image/index.rst 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-first-image/index.rst 2022-03-29 19:45:08.000000000 +0200
@@ -1,2 +1,2 @@
-.. image:: http://example.org/image2.png
+.. image:: http://example.org/en/latest/image2.png
:alt: Test image alt text
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-first-image-no-image/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-first-image-no-image/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-first-image-no-image/conf.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-first-image-no-image/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -6,7 +6,7 @@
html_theme = "basic"
ogp_site_name = "Example's Docs!"
-ogp_site_url = "http://example.org/"
-ogp_image = "http://example.org/image33.png"
+ogp_site_url = "http://example.org/en/latest/"
+ogp_image = "http://example.org/en/latest/image33.png"
ogp_image_alt = "TEST"
ogp_use_first_image = True
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-image/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-image/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-image/conf.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-image/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -6,5 +6,5 @@
html_theme = "basic"
ogp_site_name = "Example's Docs!"
-ogp_site_url = "http://example.org/"
-ogp_image = "http://example.org/image.png"
+ogp_site_url = "http://example.org/en/latest/"
+ogp_image = "http://example.org/en/latest/image.png"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-image-rel-paths/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-image-rel-paths/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-image-rel-paths/conf.py 1970-01-01 01:00:00.000000000 +0100
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-image-rel-paths/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -0,0 +1,11 @@
+extensions = ["sphinxext.opengraph"]
+
+master_doc = "index"
+exclude_patterns = ["_build"]
+
+html_theme = "basic"
+
+ogp_site_name = "Example's Docs!"
+ogp_site_url = "http://example.org/en/latest/"
+ogp_image = "_static/image33.png"
+ogp_use_first_image = True
Binary files old/sphinxext-opengraph-0.4.2/tests/roots/test-image-rel-paths/img/sample.jpg and new/sphinxext-opengraph-0.6.3/tests/roots/test-image-rel-paths/img/sample.jpg differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-image-rel-paths/index.rst new/sphinxext-opengraph-0.6.3/tests/roots/test-image-rel-paths/index.rst
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-image-rel-paths/index.rst 1970-01-01 01:00:00.000000000 +0100
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-image-rel-paths/index.rst 2022-03-29 19:45:08.000000000 +0200
@@ -0,0 +1,2 @@
+.. image:: img/sample.jpg
+ :alt: Test image alt text
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-image-rel-paths/sub/index.rst new/sphinxext-opengraph-0.6.3/tests/roots/test-image-rel-paths/sub/index.rst
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-image-rel-paths/sub/index.rst 1970-01-01 01:00:00.000000000 +0100
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-image-rel-paths/sub/index.rst 2022-03-29 19:45:08.000000000 +0200
@@ -0,0 +1,6 @@
+========
+Sub Page
+========
+
+.. image:: ../img/sample.jpg
+ :alt: Test image alt text
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-list/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-list/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-list/conf.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-list/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -5,4 +5,4 @@
html_theme = "basic"
-ogp_site_url = "http://example.org/"
+ogp_site_url = "http://example.org/en/latest/"
Binary files old/sphinxext-opengraph-0.4.2/tests/roots/test-local-image/_static/sample.jpg and new/sphinxext-opengraph-0.6.3/tests/roots/test-local-image/_static/sample.jpg differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-local-image/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-local-image/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-local-image/conf.py 1970-01-01 01:00:00.000000000 +0100
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-local-image/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -0,0 +1,10 @@
+extensions = ["sphinxext.opengraph"]
+
+master_doc = "index"
+exclude_patterns = ["_build"]
+
+html_theme = "basic"
+
+ogp_site_name = "Example's Docs!"
+ogp_site_url = "http://example.org/en/latest/"
+ogp_image = "_static/sample.jpg"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-nested-lists/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-nested-lists/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-nested-lists/conf.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-nested-lists/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -5,4 +5,4 @@
html_theme = "basic"
-ogp_site_url = "http://example.org/"
+ogp_site_url = "http://example.org/en/latest/"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-overrides-complex/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-overrides-complex/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-overrides-complex/conf.py 1970-01-01 01:00:00.000000000 +0100
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-overrides-complex/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -0,0 +1,10 @@
+extensions = ["sphinxext.opengraph"]
+
+master_doc = "index"
+exclude_patterns = ["_build"]
+
+html_theme = "basic"
+
+ogp_site_name = "Example's Docs!"
+ogp_site_url = "http://example.org/en/latest/"
+ogp_image_alt = "Example Alt Text"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-overrides-complex/index.rst new/sphinxext-opengraph-0.6.3/tests/roots/test-overrides-complex/index.rst
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-overrides-complex/index.rst 1970-01-01 01:00:00.000000000 +0100
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-overrides-complex/index.rst 2022-03-29 19:45:08.000000000 +0200
@@ -0,0 +1,7 @@
+:ogp_description_length: 10
+:og:image: img/sample.jpg
+:og:image:alt: Overridden Alt Text
+
+Lorem Ipsum
+===========
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse at lorem ornare, fringilla massa nec, venenatis mi. Donec erat sapien, tincidunt nec rhoncus nec, scelerisque id diam. Orci varius natoque penatibus et magnis dis parturient mauris.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-overrides-simple/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-overrides-simple/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-overrides-simple/conf.py 1970-01-01 01:00:00.000000000 +0100
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-overrides-simple/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -0,0 +1,11 @@
+extensions = ["sphinxext.opengraph"]
+
+master_doc = "index"
+exclude_patterns = ["_build"]
+
+html_theme = "basic"
+
+ogp_site_name = "Example's Docs!"
+ogp_site_url = "http://example.org/en/latest/"
+ogp_image = "http://example.org/en/latest/image.png"
+ogp_type = "book"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-overrides-simple/index.rst new/sphinxext-opengraph-0.6.3/tests/roots/test-overrides-simple/index.rst
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-overrides-simple/index.rst 1970-01-01 01:00:00.000000000 +0100
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-overrides-simple/index.rst 2022-03-29 19:45:08.000000000 +0200
@@ -0,0 +1,8 @@
+:og:description: Overridden description
+:og:title: Overridden Title
+:og:type: article
+:og:image: http://example.org/en/latest/overridden-image.png
+
+Lorem Ipsum
+===========
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse at lorem ornare, fringilla massa nec, venenatis mi. Donec erat sapien, tincidunt nec rhoncus nec, scelerisque id diam. Orci varius natoque penatibus et magnis dis parturient mauris.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-quotation-marks/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-quotation-marks/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-quotation-marks/conf.py 1970-01-01 01:00:00.000000000 +0100
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-quotation-marks/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -0,0 +1,10 @@
+extensions = ["sphinxext.opengraph"]
+
+master_doc = "index"
+exclude_patterns = ["_build"]
+
+html_theme = "basic"
+
+smartquotes = False
+
+ogp_site_url = "http://example.org/en/latest/"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-quotation-marks/index.rst new/sphinxext-opengraph-0.6.3/tests/roots/test-quotation-marks/index.rst
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-quotation-marks/index.rst 1970-01-01 01:00:00.000000000 +0100
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-quotation-marks/index.rst 2022-03-29 19:45:08.000000000 +0200
@@ -0,0 +1 @@
+"This text should appear in escaped quotation marks" This text should still appear as well "while this is once again in quotations"
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-simple/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-simple/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-simple/conf.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-simple/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -5,4 +5,4 @@
html_theme = "basic"
-ogp_site_url = "http://example.org/"
+ogp_site_url = "http://example.org/en/latest/"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-sitename/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-sitename/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-sitename/conf.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-sitename/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -5,5 +5,5 @@
html_theme = "basic"
-ogp_site_url = "http://example.org/"
+ogp_site_url = "http://example.org/en/latest/"
ogp_site_name = "Example's Docs!"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-skip-admonitions/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-skip-admonitions/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-skip-admonitions/conf.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-skip-admonitions/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -5,4 +5,4 @@
html_theme = "basic"
-ogp_site_url = "http://example.org/"
+ogp_site_url = "http://example.org/en/latest/"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-skip-code-block/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-skip-code-block/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-skip-code-block/conf.py 1970-01-01 01:00:00.000000000 +0100
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-skip-code-block/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -0,0 +1,9 @@
+extensions = ["sphinxext.opengraph"]
+
+master_doc = "index"
+exclude_patterns = ["_build"]
+
+html_theme = "basic"
+
+ogp_site_url = "http://example.org/en/latest/"
+ogp_description_length = 100
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-skip-code-block/index.rst new/sphinxext-opengraph-0.6.3/tests/roots/test-skip-code-block/index.rst
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-skip-code-block/index.rst 1970-01-01 01:00:00.000000000 +0100
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-skip-code-block/index.rst 2022-03-29 19:45:08.000000000 +0200
@@ -0,0 +1,7 @@
+This text should be included.
+
+.. code-block:: html
+
+ <p> This text should be skipped. </p>
+
+This text should also be included.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-skip-comments/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-skip-comments/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-skip-comments/conf.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-skip-comments/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -5,4 +5,4 @@
html_theme = "basic"
-ogp_site_url = "http://example.org/"
+ogp_site_url = "http://example.org/en/latest/"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-skip-raw/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-skip-raw/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-skip-raw/conf.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-skip-raw/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -5,5 +5,5 @@
html_theme = "basic"
-ogp_site_url = "http://example.org/"
+ogp_site_url = "http://example.org/en/latest/"
ogp_description_length = 100
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-skip-title/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-skip-title/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-skip-title/conf.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-skip-title/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -5,4 +5,4 @@
html_theme = "basic"
-ogp_site_url = "http://example.org/"
+ogp_site_url = "http://example.org/en/latest/"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/roots/test-type/conf.py new/sphinxext-opengraph-0.6.3/tests/roots/test-type/conf.py
--- old/sphinxext-opengraph-0.4.2/tests/roots/test-type/conf.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/roots/test-type/conf.py 2022-03-29 19:45:08.000000000 +0200
@@ -5,5 +5,5 @@
html_theme = "basic"
-ogp_site_url = "http://example.org/"
+ogp_site_url = "http://example.org/en/latest/"
ogp_type = "article"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinxext-opengraph-0.4.2/tests/test_options.py new/sphinxext-opengraph-0.6.3/tests/test_options.py
--- old/sphinxext-opengraph-0.4.2/tests/test_options.py 2021-05-26 13:28:12.000000000 +0200
+++ new/sphinxext-opengraph-0.6.3/tests/test_options.py 2022-03-29 19:45:08.000000000 +0200
@@ -29,12 +29,31 @@
@pytest.mark.sphinx("html", testroot="simple")
def test_site_url(og_meta_tags):
# Uses the same directory as simple, because it already contains url for a minimal config
- assert get_tag_content(og_meta_tags, "url") == "http://example.org/index.html"
+ assert (
+ get_tag_content(og_meta_tags, "url")
+ == "http://example.org/en/latest/index.html"
+ )
+
+
+@pytest.mark.sphinx("dirhtml", testroot="simple")
+def test_dirhtml_url(og_meta_tags):
+ assert get_tag_content(og_meta_tags, "url") == "http://example.org/en/latest/index/"
@pytest.mark.sphinx("html", testroot="image")
def test_image(og_meta_tags):
- assert get_tag_content(og_meta_tags, "image") == "http://example.org/image.png"
+ assert (
+ get_tag_content(og_meta_tags, "image")
+ == "http://example.org/en/latest/image.png"
+ )
+
+
+@pytest.mark.sphinx("html", testroot="local-image")
+def test_local_image(og_meta_tags):
+ assert (
+ get_tag_content(og_meta_tags, "image")
+ == "http://example.org/en/latest/_static/sample.jpg"
+ )
@pytest.mark.sphinx("html", testroot="image")
@@ -59,16 +78,34 @@
@pytest.mark.sphinx("html", testroot="first-image")
def test_first_image(og_meta_tags):
- assert get_tag_content(og_meta_tags, "image") == "http://example.org/image2.png"
+ assert (
+ get_tag_content(og_meta_tags, "image")
+ == "http://example.org/en/latest/image2.png"
+ )
assert get_tag_content(og_meta_tags, "image:alt") == "Test image alt text"
@pytest.mark.sphinx("html", testroot="first-image-no-image")
def test_first_image_no_image(og_meta_tags):
- assert get_tag_content(og_meta_tags, "image") == "http://example.org/image33.png"
+ assert (
+ get_tag_content(og_meta_tags, "image")
+ == "http://example.org/en/latest/image33.png"
+ )
assert get_tag_content(og_meta_tags, "image:alt") == "TEST"
+@pytest.mark.sphinx("html", testroot="image-rel-paths")
+def test_image_rel_paths(og_meta_tags, og_meta_tags_sub):
+ assert (
+ get_tag_content(og_meta_tags, "image")
+ == "http://example.org/en/latest/_images/sample.jpg"
+ )
+ assert (
+ get_tag_content(og_meta_tags_sub, "image")
+ == "http://example.org/en/latest/_images/sample.jpg"
+ )
+
+
@pytest.mark.sphinx("html", testroot="skip-admonitions")
def test_skip_admonitions(og_meta_tags):
assert get_tag_content(og_meta_tags, "description") == "This is text."
@@ -127,27 +164,80 @@
)
+@pytest.mark.sphinx("html", testroot="skip-code-block")
+def test_skip_code_block(og_meta_tags):
+ description = get_tag_content(og_meta_tags, "description")
+ assert "<p>" not in description
+ assert (
+ description
+ == "This text should be included. This text should also be included."
+ )
+
+
+@pytest.mark.sphinx("html", testroot="quotation-marks")
+def test_quotation_marks(og_meta_tags):
+ # If smart quotes are disabled and the quotes aren't properly escaped, bs4 will fail to parse the tag and the content will be a empty string
+ description = get_tag_content(og_meta_tags, "description")
+
+ assert (
+ description
+ == '"This text should appear in escaped quotation marks" This text should still appear as well "while this is once again in quotations"'
+ )
+
+
+@pytest.mark.sphinx("html", testroot="overrides-simple")
+def test_overrides_simple(og_meta_tags):
+ assert get_tag_content(og_meta_tags, "description") == "Overridden description"
+ assert get_tag_content(og_meta_tags, "title") == "Overridden Title"
+ assert get_tag_content(og_meta_tags, "type") == "article"
+ assert (
+ get_tag_content(og_meta_tags, "image")
+ == "http://example.org/en/latest/overridden-image.png"
+ )
+ # Make sure alt text still works even when overriding the image
+ assert get_tag_content(og_meta_tags, "image:alt") == "Example's Docs!"
+
+
+@pytest.mark.sphinx("html", testroot="overrides-complex")
+def test_overrides_complex(og_meta_tags):
+ assert len(get_tag_content(og_meta_tags, "description")) == 10
+ assert (
+ get_tag_content(og_meta_tags, "image")
+ == "http://example.org/en/latest/img/sample.jpg"
+ )
+ assert get_tag_content(og_meta_tags, "image:alt") == "Overridden Alt Text"
+
+
+@pytest.mark.sphinx("html", testroot="arbitrary-tags")
+def test_arbitrary_tags(og_meta_tags):
+ assert (
+ get_tag_content(og_meta_tags, "video")
+ == "http://example.org/en/latest/video.mp4"
+ )
+ assert get_tag_content(og_meta_tags, "video:type") == "video/mp4"
+
+
# use same as simple, as configuration is identical to overriden
@pytest.mark.sphinx("html", testroot="simple")
def test_rtd_override(app: Sphinx, monkeypatch):
monkeypatch.setenv("READTHEDOCS", "True")
- app.config.html_baseurl = "https://failure.com"
+ app.config.html_baseurl = "https://failure.com/en/latest/"
app.build()
tags = conftest._og_meta_tags(app)
- assert get_tag_content(tags, "url") == "http://example.org/index.html"
+ assert get_tag_content(tags, "url") == "http://example.org/en/latest/index.html"
@pytest.mark.sphinx("html", testroot="rtd-default")
def test_rtd_valid(app: Sphinx, monkeypatch):
monkeypatch.setenv("READTHEDOCS", "True")
- app.config.html_baseurl = "https://failure.com"
+ app.config.html_baseurl = "https://failure.com/en/latest/"
app.build()
tags = conftest._og_meta_tags(app)
- assert get_tag_content(tags, "url") == "https://failure.com/index.html"
+ assert get_tag_content(tags, "url") == "https://failure.com/en/latest/index.html"
# use rtd-default, as we are not changing configuration, but RTD variables