Skip to content

Commit

Permalink
Improve sponsor handling
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Jul 17, 2024
1 parent 829c2ff commit 05eb7f0
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ build:
post_checkout:
- git fetch --tags

# Replace versions in sponsor URLs
pre_build:
- cog -rP docs/index.md

python:
install:
- method: pip
Expand Down
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,26 @@ Its main goal is to help you to write **concise** and **correct** software witho
*attrs* would not be possible without our [amazing sponsors](https://github.com/sponsors/hynek).
Especially those generously supporting us at the *The Organization* tier and higher:

<!-- sponsor-break-begin -->

<p align="center">
<a href="https://www.variomedia.de/"><img src="https://www.attrs.org/en/latest/_static/sponsors/Variomedia.svg" width="200" height="60" /></a>
<a href="https://tidelift.com/subscription/pkg/pypi-attrs?utm_source=pypi-attrs&utm_medium=referral&utm_campaign=enterprise&utm_term=repo"><img src="https://www.attrs.org/en/latest/_static/sponsors/Tidelift.svg" width="200" height="60" /></a>
<a href="https://klaviyo.com/"><img src="https://www.attrs.org/en/latest/_static/sponsors/Klaviyo.svg" width="200" height="60"/></a>
<a href="https://filepreviews.io/"><img src="https://www.attrs.org/en/latest/_static/sponsors/FilePreviews.svg" width="200" height="60"/></a>

<!-- [[[cog
import pathlib, tomllib
for sponsor in tomllib.loads(pathlib.Path("pyproject.toml").read_text())["tool"]["sponcon"]["sponsors"]:
print(f'<a href="{sponsor["url"]}"><img title="{sponsor["title"]}" src="docs/_static/sponsors/{sponsor["img"]}" width="200" height="60" /></a>')
]]] -->
<a href="https://www.variomedia.de/"><img title="Variomedia AG" src="docs/_static/sponsors/Variomedia.svg" width="200" height="60" /></a>
<a href="https://tidelift.com/?utm_source=lifter&utm_medium=referral&utm_campaign=hynek"><img title="Tidelift" src="docs/_static/sponsors/Tidelift.svg" width="200" height="60" /></a>
<a href="https://klaviyo.com/"><img title="Klaviyo" src="docs/_static/sponsors/Klaviyo.svg" width="200" height="60" /></a>
<a href="https://filepreviews.io/"><img title="FilePreviews" src="docs/_static/sponsors/FilePreviews.svg" width="200" height="60" /></a>
<!-- [[[end]]] -->

</p>

<!-- sponsor-break-end -->

<p align="center">
<strong>Please consider <a href="https://github.com/sponsors/hynek">joining them</a> to help make <em>attrs</em>’s maintenance more sustainable!</strong>
</p>
Expand Down
22 changes: 22 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ Release **{sub-ref}`release`** ([What's new?](changelog.md))

```{include} ../README.md
:start-after: 'teaser-begin -->'
:end-before: '<!-- sponsor-break-begin'
```

<!-- [[[cog
# This is mainly called from RTD's pre_build job!
import pathlib, tomllib, importlib.metadata
if "dev" in (version := importlib.metadata.version("attrs")):
version = "latest"
for sponsor in tomllib.loads(pathlib.Path("pyproject.toml").read_text())["tool"]["sponcon"]["sponsors"]:
print(f'<a href="{sponsor["url"]}"><img title="{sponsor["title"]}" src="/en/{version}/_static/sponsors/{sponsor["img"]}" width="200" height="60" /></a>')
]]] -->
<a href="https://www.variomedia.de/"><img title="Variomedia AG" src="/en/latest/_static/sponsors/Variomedia.svg" width="200" height="60" /></a>
<a href="https://tidelift.com/?utm_source=lifter&utm_medium=referral&utm_campaign=hynek"><img title="Tidelift" src="/en/latest/_static/sponsors/Tidelift.svg" width="200" height="60" /></a>
<a href="https://klaviyo.com/"><img title="Klaviyo" src="/en/latest/_static/sponsors/Klaviyo.svg" width="200" height="60" /></a>
<a href="https://filepreviews.io/"><img title="FilePreviews" src="/en/latest/_static/sponsors/FilePreviews.svg" width="200" height="60" /></a>
<!-- [[[end]]] -->

```{include} ../README.md
:start-after: 'sponsor-break-end -->'
:end-before: '<!-- teaser-end'
```

Expand Down
25 changes: 23 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ cov = [
"coverage[toml]>=5.3",
]
docs = [
"cogapp",
"furo",
"myst-parser",
"sphinx",
Expand Down Expand Up @@ -115,8 +116,28 @@ text = """

# Point sponsor image URLs to versions.
[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
pattern = '\/latest\/_static/sponsors'
replacement = '/$HFPR_VERSION/_static/sponsors'
pattern = 'docs\/_static\/sponsors'
replacement = 'https://www.attrs.org/en/$HFPR_VERSION/_static/sponsors'

[[tool.sponcon.sponsors]]
title = "Variomedia AG"
url = "https://www.variomedia.de/"
img = "Variomedia.svg"

[[tool.sponcon.sponsors]]
title = "Tidelift"
url = "https://tidelift.com/?utm_source=lifter&utm_medium=referral&utm_campaign=hynek"
img = "Tidelift.svg"

[[tool.sponcon.sponsors]]
title = "Klaviyo"
url = "https://klaviyo.com/"
img = "Klaviyo.svg"

[[tool.sponcon.sponsors]]
title = "FilePreviews"
url = "https://filepreviews.io/"
img = "FilePreviews.svg"


[tool.pytest.ini_options]
Expand Down
8 changes: 7 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env_list =
py3{9,10,11,12,13}-mypy,
pypy3,
pyright,
docs,
docs{,-sponsors},
changelog,
coverage-report

Expand Down Expand Up @@ -88,6 +88,12 @@ extras = {[testenv:docs]extras}
commands = sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees docs docs/_build/html


[testenv:docs-sponsors]
description = Ensure sponsor logos are up to date.
deps = cogapp
commands = cog -rP README.md docs/index.md


[testenv:pre-commit]
skip_install = true
deps = pre-commit
Expand Down

0 comments on commit 05eb7f0

Please sign in to comment.