Skip to content

Commit

Permalink
chore: Template upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Aug 20, 2024
1 parent 1c9bda1 commit 57998bf
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
_commit: 1.2.8
_commit: 1.4.0
_src_path: gh:pawamoy/copier-uv
author_email: dev@pawamoy.fr
author_fullname: Timothée Mazzucotelli
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ PASTE TRACEBACK HERE
python -m mkdocs_autorefs.debug # | xclip -selection clipboard
```

PASTE OUTPUT HERE
PASTE MARKDOWN OUTPUT HERE

### Additional context
<!-- Add any other relevant context about the problem here,
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/3-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Documentation update
about: Point at unclear, missing or outdated documentation.
title: "docs: "
labels: docs
assignees: pawamoy
---

### Is something unclear, missing or outdated in our documentation?
<!-- A clear and concise description of what the documentation issue is. Ex. I can't find an explanation on feature [...]. -->

### Relevant code snippets
<!-- If the documentation issue is related to code, please provide relevant code snippets. -->

### Link to the relevant documentation section
<!-- Add a link to the relevant section of our documentation, or any addition context. -->
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/4-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Change request
about: Suggest any other kind of change for this project.
title: "change: "
assignees: pawamoy
---

### Is your change request related to a problem? Please describe.
<!-- A clear and concise description of what the problem is. -->

### Describe the solution you'd like
<!-- A clear and concise description of what you want to happen. -->

### Describe alternatives you've considered
<!-- A clear and concise description of any alternative solutions you've considered. -->

### Additional context
<!-- Add any other context or screenshots about the change request here. -->
12 changes: 5 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ Run `make help` to see all the available actions!
## Tasks
This project uses [duty](https://github.com/pawamoy/duty) to run tasks.
A Makefile is also provided. The Makefile will try to run certain tasks
on multiple Python versions. If for some reason you don't want to run the task
on multiple Python versions, you run the task directly with `make run duty TASK`.
The Makefile detects if a virtual environment is activated,
so `make` will work the same with the virtualenv activated or not.
The entry-point to run commands and tasks is the `make` Python script,
located in the `scripts` directory. Try running `make` to show the available commands and tasks.
The *commands* do not need the Python dependencies to be installed,
while the *tasks* do.
The cross-platform tasks are written in Python, thanks to [duty](https://github.com/pawamoy/duty).
If you work in VSCode, we provide
[an action to configure VSCode](https://pawamoy.github.io/copier-uv/work/#vscode-setup)
Expand Down
2 changes: 1 addition & 1 deletion devdeps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ editables>=0.5
# maintenance
build>=1.2
git-changelog>=2.5
twine>=5.1; python_version < '3.13'
twine>=5.0; python_version < '3.13'

# ci
duty>=1.4
Expand Down
57 changes: 57 additions & 0 deletions docs/.overrides/partials/comments.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!-- Giscus -->
<!-- https://squidfunk.github.io/mkdocs-material/setup/adding-a-comment-system/#giscus-integration -->
<div id="feedback" style="display: none;">
<h2 id="__comments">Feedback</h2>
<script src="https://giscus.app/client.js"
data-repo="mkdocstrings/autorefs"
data-repo-id="MDEwOlJlcG9zaXRvcnkzMzc2NTE2NjM="
data-category="Documentation"
data-category-id="DIC_kwDOFCAnz84Chq2b"
data-mapping="pathname"
data-strict="1"
data-reactions-enabled="0"
data-emit-metadata="0"
data-input-position="top"
data-theme="preferred_color_scheme"
data-lang="en"
data-loading="lazy"
crossorigin="anonymous"
async>
</script>

<!-- Synchronize Giscus theme with palette -->
<script>
var giscus = document.querySelector("script[src*=giscus]")

// Set palette on initial load
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object") {
var theme = palette.color.scheme === "slate"
? "transparent_dark"
: "light"

// Instruct Giscus to set theme
giscus.setAttribute("data-theme", theme)
}

// Register event handlers after documented loaded
document.addEventListener("DOMContentLoaded", function() {
var ref = document.querySelector("[data-md-component=palette]")
ref.addEventListener("change", function() {
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object") {
var theme = palette.color.scheme === "slate"
? "transparent_dark"
: "light"

// Instruct Giscus to change theme
var frame = document.querySelector(".giscus-frame")
frame.contentWindow.postMessage(
{ giscus: { setConfig: { theme } } },
"https://giscus.app"
)
}
})
})
</script>
</div>
5 changes: 5 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
---
hide:
- feedback
---

--8<-- "README.md"
14 changes: 14 additions & 0 deletions docs/js/feedback.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const feedback = document.forms.feedback;
feedback.hidden = false;

feedback.addEventListener("submit", function(ev) {
ev.preventDefault();
const commentElement = document.getElementById("feedback");
commentElement.style.display = "block";
feedback.firstElementChild.disabled = true;
const data = ev.submitter.getAttribute("data-md-value");
const note = feedback.querySelector(".md-feedback__note [data-md-value='" + data + "']");
if (note) {
note.hidden = false;
}
})
5 changes: 5 additions & 0 deletions docs/license.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
hide:
- feedback
---

# License

```
Expand Down
15 changes: 15 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ extra_css:
- css/material.css
- css/mkdocstrings.css

extra_javascript:
- js/feedback.js

markdown_extensions:
- attr_list
- admonition
Expand Down Expand Up @@ -146,3 +149,15 @@ extra:
link: https://gitter.im/mkdocstrings/autorefs
- icon: fontawesome/brands/python
link: https://pypi.org/project/mkdocs-autorefs/
analytics:
feedback:
title: Was this page helpful?
ratings:
- icon: material/emoticon-happy-outline
name: This page was helpful
data: 1
note: Thanks for your feedback!
- icon: material/emoticon-sad-outline
name: This page could be improved
data: 0
note: Let us know how we can improve this page.
14 changes: 13 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,19 @@ version = {source = "scm"}
[tool.pdm.build]
package-dir = "src"
editable-backend = "editables"
source-includes = ["share"]
excludes = ["**/.pytest_cache"]
source-includes = [
"config",
"docs",
"scripts",
"share",
"tests",
"devdeps.txt",
"duties.py",
"mkdocs.yml",
"*.md",
"LICENSE",
]

[tool.pdm.build.wheel-data]
data = [
Expand Down
19 changes: 13 additions & 6 deletions scripts/make
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python3
"""Management commands."""

from __future__ import annotations

import os
import shutil
import subprocess
Expand All @@ -15,9 +17,12 @@ exe = ""
prefix = ""


def shell(cmd: str) -> None:
def shell(cmd: str, capture_output: bool = False, **kwargs: Any) -> str | None:
"""Run a shell command."""
subprocess.run(cmd, shell=True, check=True) # noqa: S602
if capture_output:
return subprocess.check_output(cmd, shell=True, text=True, **kwargs) # noqa: S602
subprocess.run(cmd, shell=True, check=True, stderr=subprocess.STDOUT, **kwargs) # noqa: S602
return None


@contextmanager
Expand All @@ -37,8 +42,8 @@ def uv_install() -> None:
uv_opts = ""
if "UV_RESOLUTION" in os.environ:
uv_opts = f"--resolution={os.getenv('UV_RESOLUTION')}"
cmd = f"uv pip compile {uv_opts} pyproject.toml devdeps.txt | uv pip install -r -"
shell(cmd)
requirements = shell(f"uv pip compile {uv_opts} pyproject.toml devdeps.txt", capture_output=True)
shell("uv pip install -r -", input=requirements, text=True)
if "CI" not in os.environ:
shell("uv pip install --no-deps -e .")
else:
Expand Down Expand Up @@ -199,5 +204,7 @@ def main() -> int:
if __name__ == "__main__":
try:
sys.exit(main())
except Exception: # noqa: BLE001
sys.exit(1)
except subprocess.CalledProcessError as process:
if process.output:
print(process.output, file=sys.stderr) # noqa: T201
sys.exit(process.returncode)

0 comments on commit 57998bf

Please sign in to comment.