add missing docstrings

This commit is contained in:
Bastian Venthur
2023-09-20 15:09:28 +02:00
parent 4f3516fb19
commit c92130559c
12 changed files with 72 additions and 10 deletions

View File

@@ -1,8 +1,6 @@
#!/usr/bin/env python3
"""blag's core methods.
"""
"""blag's core methods."""
# remove when we don't support py38 anymore
from __future__ import annotations
@@ -32,7 +30,7 @@ logging.basicConfig(
def main(arguments: list[str] | None = None) -> None:
"""Main entrypoint for the CLI.
"""Run the CLI.
This method parses the CLI arguments and executes the respective
commands.
@@ -328,7 +326,7 @@ def process_markdown(
for src, dst in convertibles:
logger.debug(f"Processing {src}")
with open(f"{input_dir}/{src}", "r") as fh:
with open(f"{input_dir}/{src}") as fh:
body = fh.read()
content, meta = convert_markdown(md, body)

View File

@@ -94,9 +94,10 @@ def convert_markdown(
class MarkdownLinkTreeprocessor(Treeprocessor):
"""Converts relative links to .md files to .html"""
"""Converts relative links to .md files to .html."""
def run(self, root: Element) -> Element:
"""Process the ElementTree."""
for element in root.iter():
if element.tag == "a":
url = element.get("href")
@@ -109,6 +110,7 @@ class MarkdownLinkTreeprocessor(Treeprocessor):
return root
def convert(self, url: str) -> str:
"""Convert relative .md-links to .html-links."""
scheme, netloc, path, query, fragment = urlsplit(url)
logger.debug(
f"{url}: {scheme=} {netloc=} {path=} {query=} {fragment=}"
@@ -126,6 +128,7 @@ class MarkdownLinkExtension(Extension):
"""markdown.extension that converts relative .md- to .html-links."""
def extendMarkdown(self, md: Markdown) -> None:
"""Register the MarkdownLinkTreeprocessor."""
md.treeprocessors.register(
MarkdownLinkTreeprocessor(md),
"mdlink",

View File

@@ -1,6 +1,4 @@
"""Helper methods for blag's quickstart command.
"""
"""Helper methods for blag's quickstart command."""
# remove when we don't support py38 anymore
from __future__ import annotations

View File

@@ -1 +1,3 @@
"""Version information for the blag package."""
__VERSION__ = "2.1.0"