Skip to content

Commit b5da541

Browse files
authored
Merge pull request #400 from danielparks/pypi-readme
Fix README on PyPi
2 parents 7faadc0 + ea67fae commit b5da541

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ licenses. You may choose to use either.
105105
* [Apache License, Version 2.0](LICENSE-APACHE)
106106
* [MIT license](LICENSE-MIT)
107107

108+
<!-- GitHub only -->
108109
Files in the `asl` directory are not licensed for redistribution. Copyright is
109110
somewhat unclear, and at least some of the material is owned by [Dr. William
110111
Vicars][LP].
112+
<!-- /GitHub only -->
111113

112114
[Anki]: https://apps.ankiweb.net
113115
[yt-dlp]: https://github.com/yt-dlp/yt-dlp

pyproject.toml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
[project]
22
name = "yanki"
3-
dynamic = ["version"]
3+
dynamic = ["readme", "version"]
44
description = "Build Anki decks from text files containing YouTube URLs."
55
authors = [{name = "Daniel Parks", email = "oss-yanki@demonhorse.org"}]
6-
readme = "README.md"
76
requires-python = ">= 3.11"
87
license = "MIT OR Apache-2.0"
98
license-files = ["LICENSE-*"]
@@ -99,7 +98,7 @@ packages = ["yanki"]
9998
path = "yanki/__version__.py"
10099

101100
[build-system]
102-
requires = ["hatchling"]
101+
requires = ["hatchling", "hatch-fancy-pypi-readme"]
103102
build-backend = "hatchling.build"
104103

105104
[tool.hatch.build.targets.sdist]
@@ -111,3 +110,22 @@ include = [
111110
"/web-files",
112111
"/yanki",
113112
]
113+
114+
[tool.hatch.metadata.hooks.fancy-pypi-readme]
115+
content-type = "text/markdown"
116+
fragments = [{path = "README.md"}]
117+
118+
[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
119+
# Remove GitHub only sections from README.md.
120+
pattern = '(?s)<!-- GitHub only -->.+<!-- /GitHub only -->'
121+
replacement = ''
122+
123+
[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
124+
# Replace GitHub-specific [!TIP] syntax.
125+
pattern = '\[!TIP\]'
126+
replacement = '### 💡 Tip'
127+
128+
[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
129+
# Make links to package files absolute GitHub links.
130+
pattern = '(?m)^(\[.+?\]):\s*((?!\w+:)\S+)'
131+
replacement = '\1: https://github.com/danielparks/yanki/blob/v$HFPR_VERSION/\2'

0 commit comments

Comments
 (0)