formatted python files
This commit is contained in:
parent
faac8f63bb
commit
04948a9373
5 changed files with 34 additions and 13 deletions
|
@ -48,7 +48,9 @@ class ZonaBuilder:
|
|||
destination=destination,
|
||||
url=str(destination.relative_to(layout.output)),
|
||||
)
|
||||
if path.name.endswith(".md") and not path.is_relative_to(
|
||||
if path.name.endswith(
|
||||
".md"
|
||||
) and not path.is_relative_to(
|
||||
layout.root / "content" / "static"
|
||||
):
|
||||
logger.debug(f"Parsing {path.name}.")
|
||||
|
@ -69,11 +71,13 @@ class ZonaBuilder:
|
|||
item.copy = False
|
||||
name = destination.stem
|
||||
if name == "index":
|
||||
item.destination = item.destination.with_suffix(
|
||||
".html"
|
||||
item.destination = (
|
||||
item.destination.with_suffix(".html")
|
||||
)
|
||||
else:
|
||||
relative = path.relative_to(base).with_suffix("")
|
||||
relative = path.relative_to(base).with_suffix(
|
||||
""
|
||||
)
|
||||
name = relative.stem
|
||||
item.destination = (
|
||||
layout.output
|
||||
|
@ -85,7 +89,9 @@ class ZonaBuilder:
|
|||
layout.output
|
||||
)
|
||||
item.url = (
|
||||
"" if rel_url == Path(".") else rel_url.as_posix()
|
||||
""
|
||||
if rel_url == Path(".")
|
||||
else rel_url.as_posix()
|
||||
)
|
||||
items.append(item)
|
||||
self.items = items
|
||||
|
@ -111,7 +117,9 @@ class ZonaBuilder:
|
|||
# write code highlighting stylesheet
|
||||
if self.config.markdown.syntax_highlighting.enabled:
|
||||
pygments_style = zmd.get_style_defs(self.config)
|
||||
pygments_path = self.layout.output / "static" / "pygments.css"
|
||||
pygments_path = (
|
||||
self.layout.output / "static" / "pygments.css"
|
||||
)
|
||||
util.ensure_parents(pygments_path)
|
||||
pygments_path.write_text(pygments_style)
|
||||
for item in self.item_map.values():
|
||||
|
|
|
@ -59,7 +59,9 @@ def build(
|
|||
"""
|
||||
if draft:
|
||||
print("Option override: including drafts.")
|
||||
builder = ZonaBuilder(cli_root=root, cli_output=output, draft=draft)
|
||||
builder = ZonaBuilder(
|
||||
cli_root=root, cli_output=output, draft=draft
|
||||
)
|
||||
builder.build()
|
||||
|
||||
|
||||
|
@ -73,7 +75,9 @@ def serve(
|
|||
] = None,
|
||||
host: Annotated[
|
||||
str,
|
||||
typer.Option("--host", help="Hostname for live preview server."),
|
||||
typer.Option(
|
||||
"--host", help="Hostname for live preview server."
|
||||
),
|
||||
] = "localhost",
|
||||
port: Annotated[
|
||||
int,
|
||||
|
|
|
@ -76,7 +76,9 @@ IGNORELIST = [".marksman.toml"]
|
|||
class ZonaConfig:
|
||||
base_url: str = "/"
|
||||
# dictionary where key is name, value is url
|
||||
sitemap: SitemapConfig = field(default_factory=lambda: {"Home": "/"})
|
||||
sitemap: SitemapConfig = field(
|
||||
default_factory=lambda: {"Home": "/"}
|
||||
)
|
||||
# list of globs relative to content that should be ignored
|
||||
ignore: list[str] = field(default_factory=lambda: IGNORELIST)
|
||||
markdown: MarkdownConfig = field(default_factory=MarkdownConfig)
|
||||
|
|
|
@ -238,7 +238,9 @@ def serve(
|
|||
event_handler, path=str(root / "content"), recursive=True
|
||||
)
|
||||
observer.schedule(
|
||||
event_handler, path=str(root / "templates"), recursive=True
|
||||
event_handler,
|
||||
path=str(root / "templates"),
|
||||
recursive=True,
|
||||
)
|
||||
observer.start()
|
||||
|
||||
|
|
|
@ -19,7 +19,9 @@ def get_resource(path: str) -> ZonaResource:
|
|||
if file.is_file():
|
||||
return ZonaResource(name=path, contents=file.read_text())
|
||||
else:
|
||||
raise FileNotFoundError(f"{path} is not a valid Zona resource!")
|
||||
raise FileNotFoundError(
|
||||
f"{path} is not a valid Zona resource!"
|
||||
)
|
||||
|
||||
|
||||
def get_resources(subdir: str) -> list[ZonaResource]:
|
||||
|
@ -75,10 +77,13 @@ def normalize_url(url: str) -> str:
|
|||
return url
|
||||
|
||||
|
||||
def should_ignore(path: Path, patterns: list[str], base: Path) -> bool:
|
||||
def should_ignore(
|
||||
path: Path, patterns: list[str], base: Path
|
||||
) -> bool:
|
||||
rel_path = path.relative_to(base)
|
||||
return any(
|
||||
fnmatch.fnmatch(str(rel_path), pattern) for pattern in patterns
|
||||
fnmatch.fnmatch(str(rel_path), pattern)
|
||||
for pattern in patterns
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue