mirror of
https://github.com/astral-sh/uv.git
synced 2026-05-06 08:56:53 -04:00
Configure prettier prose-wrap in .prettierrc instead of the CLI (#17184)
This also removes the file-specific targets from prettier execution which means we're including `.json`, `.css`, and `.html` files, which seems like an improvement. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -35,14 +35,12 @@ def format_python(file_path: str, cwd: str) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def format_prettier(file_path: str, cwd: str, prose_wrap: bool = False) -> None:
|
||||
def format_prettier(file_path: str, cwd: str) -> None:
|
||||
"""Format files with prettier."""
|
||||
args = ["npx", "prettier", "--write"]
|
||||
if prose_wrap:
|
||||
args.extend(["--prose-wrap", "always"])
|
||||
args.append(file_path)
|
||||
try:
|
||||
subprocess.run(args, cwd=cwd, capture_output=True)
|
||||
subprocess.run(
|
||||
["npx", "prettier", "--write", file_path], cwd=cwd, capture_output=True
|
||||
)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
@@ -71,10 +69,8 @@ def main() -> None:
|
||||
format_rust(file_path, cwd)
|
||||
elif ext in (".py", ".pyi"):
|
||||
format_python(file_path, cwd)
|
||||
elif ext in (".json5", ".yaml", ".yml"):
|
||||
elif ext in (".json5", ".yaml", ".yml", ".md"):
|
||||
format_prettier(file_path, cwd)
|
||||
elif ext == ".md":
|
||||
format_prettier(file_path, cwd, prose_wrap=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -104,9 +104,7 @@ jobs:
|
||||
run: cargo fmt --all --check
|
||||
|
||||
- name: "Prettier"
|
||||
run: |
|
||||
npx prettier --check "**/*.{json5,yaml,yml}"
|
||||
npx prettier --prose-wrap always --check "**/*.md"
|
||||
run: npx prettier --check .
|
||||
|
||||
- name: "README check"
|
||||
run: python scripts/transform_readme.py --target pypi
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.md"],
|
||||
"options": {
|
||||
"proseWrap": "always"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
+2
-2
@@ -208,14 +208,14 @@ Cloudflare Pages.
|
||||
After making changes to the documentation, format the markdown files with:
|
||||
|
||||
```shell
|
||||
npx prettier --prose-wrap always --write "**/*.md"
|
||||
npx prettier --write "**/*.md"
|
||||
```
|
||||
|
||||
Note that the command above requires Node.js and npm to be installed on your system. As an
|
||||
alternative, you can run this command using Docker:
|
||||
|
||||
```console
|
||||
$ docker run --rm -v .:/src/ -w /src/ node:alpine npx prettier --prose-wrap always --write "**/*.md"
|
||||
$ docker run --rm -v .:/src/ -w /src/ node:alpine npx prettier --write "**/*.md"
|
||||
```
|
||||
|
||||
## Releases
|
||||
|
||||
+39
-26
@@ -1,34 +1,47 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block htmltitle %}
|
||||
{% if page.meta and page.meta.title %}
|
||||
{% extends "base.html" %} {% block htmltitle %} {% if page.meta and
|
||||
page.meta.title %}
|
||||
<title>{{ page.meta.title }} | {{ config.site_name }}</title>
|
||||
{% elif page.title and not page.is_homepage %}
|
||||
<title>{{ page.title | striptags }} | {{ config.site_name }}</title>
|
||||
{% else %}
|
||||
<title>{{ config.site_name }}</title>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extrahead %}
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="https://docs.astral.sh/static/apple-touch-icon.png"/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="https://docs.astral.sh/static/favicon-32x32.png"/>
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="https://docs.astral.sh/static/favicon-16x16.png"/>
|
||||
<link rel="manifest" href="https://docs.astral.sh/static/site.webmanifest"/>
|
||||
<link rel="mask-icon" href="https://docs.astral.sh/static/safari-pinned-tab.svg" color="#2e183d"/>
|
||||
<meta name="msapplication-TileColor" content="#d7ff64"/>
|
||||
<meta name="theme-color" content="#ffffff"/>
|
||||
<meta name="robots" content="index,follow"/>
|
||||
{% endif %} {% endblock %} {% block extrahead %}
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="180x180"
|
||||
href="https://docs.astral.sh/static/apple-touch-icon.png"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="32x32"
|
||||
href="https://docs.astral.sh/static/favicon-32x32.png"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="16x16"
|
||||
href="https://docs.astral.sh/static/favicon-16x16.png"
|
||||
/>
|
||||
<link rel="manifest" href="https://docs.astral.sh/static/site.webmanifest" />
|
||||
<link
|
||||
rel="mask-icon"
|
||||
href="https://docs.astral.sh/static/safari-pinned-tab.svg"
|
||||
color="#2e183d"
|
||||
/>
|
||||
<meta name="msapplication-TileColor" content="#d7ff64" />
|
||||
<meta name="theme-color" content="#ffffff" />
|
||||
<meta name="robots" content="index,follow" />
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
{% if page and page.meta.git_revision_date_localized_raw_iso_datetime %}
|
||||
"datePublished": "{{ page.meta.git_revision_date_localized_raw_iso_datetime }}Z",
|
||||
"dateModified": "{{ page.meta.git_revision_date_localized_raw_iso_datetime }}Z",
|
||||
{% endif %}
|
||||
"@context": "https://schema.org",
|
||||
"@type": "WebSite",
|
||||
"name": "Astral Docs",
|
||||
"url": "https://docs.astral.sh"
|
||||
}
|
||||
{
|
||||
{% if page and page.meta.git_revision_date_localized_raw_iso_datetime %}
|
||||
"datePublished": "{{ page.meta.git_revision_date_localized_raw_iso_datetime }}Z",
|
||||
"dateModified": "{{ page.meta.git_revision_date_localized_raw_iso_datetime }}Z",
|
||||
{% endif %}
|
||||
"@context": "https://schema.org",
|
||||
"@type": "WebSite",
|
||||
"name": "Astral Docs",
|
||||
"url": "https://docs.astral.sh"
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
<script src="https://cdn.usefathom.com/script.js" data-site="ESKBRHGN" defer></script>
|
||||
<script
|
||||
src="https://cdn.usefathom.com/script.js"
|
||||
data-site="ESKBRHGN"
|
||||
defer
|
||||
></script>
|
||||
|
||||
+4
-4
@@ -8,8 +8,8 @@ function cleanupClipboardText(targetSelector) {
|
||||
.filter(
|
||||
(node) =>
|
||||
!excludedClasses.some((className) =>
|
||||
node?.classList?.contains(className)
|
||||
)
|
||||
node?.classList?.contains(className),
|
||||
),
|
||||
)
|
||||
.map((node) => node.textContent)
|
||||
.filter((s) => s != "");
|
||||
@@ -23,7 +23,7 @@ function setCopyText() {
|
||||
const attr = "clipboardText";
|
||||
// all "copy" buttons whose target selector is a <code> element
|
||||
const elements = document.querySelectorAll(
|
||||
'button[data-clipboard-target$="code"]'
|
||||
'button[data-clipboard-target$="code"]',
|
||||
);
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
entries.forEach((entry) => {
|
||||
@@ -33,7 +33,7 @@ function setCopyText() {
|
||||
entry.target.dataset[attr] === undefined
|
||||
) {
|
||||
entry.target.dataset[attr] = cleanupClipboardText(
|
||||
entry.target.dataset.clipboardTarget
|
||||
entry.target.dataset.clipboardTarget,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -125,7 +125,6 @@ See https://github.com/astral-sh/uv/issues/5130 */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Always take the full screen for content, require scrolling to see the footer
|
||||
This stops the size of the nav from jumping around when you visit a page without
|
||||
a lot of content (i.e., an overview page). We don't apply this to sma screens
|
||||
@@ -144,8 +143,8 @@ because the nav is in a hamburger menu anyway
|
||||
}
|
||||
/* Remove the bold from the section headings, use a larger font instead */
|
||||
.md-nav__item--section > .md-nav__link {
|
||||
font-weight: normal;
|
||||
font-size: 0.85rem;
|
||||
font-weight: normal;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
/* Reducing spacing between nav items to fit more content
|
||||
First, disable `nav__link` spacing then use `nav__item` to enforce margins this reduces inconsistencies in the spacing. */
|
||||
@@ -161,15 +160,32 @@ because the nav is in a hamburger menu anyway
|
||||
margin-top: 1em;
|
||||
}
|
||||
/* Decrease the font size of items in a collapsible section */
|
||||
.md-nav__item--section> .md-nav > .md-nav__list > .md-nav__item > .md-nav > .md-nav__list {
|
||||
.md-nav__item--section
|
||||
> .md-nav
|
||||
> .md-nav__list
|
||||
> .md-nav__item
|
||||
> .md-nav
|
||||
> .md-nav__list {
|
||||
font-size: 0.725rem;
|
||||
}
|
||||
/* Increase top margin on the first item of a collapsible section */
|
||||
.md-nav__item--section> .md-nav > .md-nav__list > .md-nav__item > .md-nav > .md-nav__list > .md-nav__item:first-of-type {
|
||||
.md-nav__item--section
|
||||
> .md-nav
|
||||
> .md-nav__list
|
||||
> .md-nav__item
|
||||
> .md-nav
|
||||
> .md-nav__list
|
||||
> .md-nav__item:first-of-type {
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
/* Increase bottom margin on the last item of a collapsible section */
|
||||
.md-nav__item--section> .md-nav > .md-nav__list > .md-nav__item > .md-nav > .md-nav__list > .md-nav__item:last-of-type {
|
||||
.md-nav__item--section
|
||||
> .md-nav
|
||||
> .md-nav__list
|
||||
> .md-nav__item
|
||||
> .md-nav
|
||||
> .md-nav__list
|
||||
> .md-nav__item:last-of-type {
|
||||
margin-bottom: 0.575em;
|
||||
}
|
||||
/* Increase the size of the first nav item to match the sections
|
||||
@@ -186,7 +202,9 @@ because the nav is in a hamburger menu anyway
|
||||
}
|
||||
|
||||
/* See: https://mkdocstrings.github.io/recipes/#prevent-selection-of-prompts-and-output-in-python-code-blocks */
|
||||
.highlight .gp, .highlight .go { /* Generic.Prompt, Generic.Output */
|
||||
.highlight .gp,
|
||||
.highlight .go {
|
||||
/* Generic.Prompt, Generic.Output */
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
|
||||
@@ -150,8 +150,7 @@ def main() -> None:
|
||||
|
||||
# Format all generated READMEs once at the end
|
||||
subprocess.run(
|
||||
["npx", "prettier", "--write", "--prose-wrap", "always"]
|
||||
+ [str(path) for path in generated_paths],
|
||||
["npx", "prettier", "--write"] + [str(path) for path in generated_paths],
|
||||
check=True,
|
||||
)
|
||||
|
||||
|
||||
Generated
+119
-464
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user