Two empty lines after imports also in guide
This commit is contained in:
parent
53b7412c01
commit
6fac60c6fe
|
@ -5,6 +5,7 @@ from textwrap import indent
|
||||||
|
|
||||||
from emoji import EMOJI
|
from emoji import EMOJI
|
||||||
|
|
||||||
|
|
||||||
COLUMN_PATTERN = re.compile(r"---:1\s*(.*?)\s*:--:1\s*(.*?)\s*:---", re.DOTALL)
|
COLUMN_PATTERN = re.compile(r"---:1\s*(.*?)\s*:--:1\s*(.*?)\s*:---", re.DOTALL)
|
||||||
PYTHON_HIGHLIGHT_PATTERN = re.compile(r"```python\{+.*?\}", re.DOTALL)
|
PYTHON_HIGHLIGHT_PATTERN = re.compile(r"```python\{+.*?\}", re.DOTALL)
|
||||||
BASH_HIGHLIGHT_PATTERN = re.compile(r"```bash\{+.*?\}", re.DOTALL)
|
BASH_HIGHLIGHT_PATTERN = re.compile(r"```bash\{+.*?\}", re.DOTALL)
|
||||||
|
|
|
@ -3,5 +3,3 @@ extend = "../pyproject.toml"
|
||||||
|
|
||||||
[tool.ruff.isort]
|
[tool.ruff.isort]
|
||||||
known-first-party = ["webapp"]
|
known-first-party = ["webapp"]
|
||||||
lines-after-imports = 1
|
|
||||||
lines-between-types = 1
|
|
||||||
|
|
|
@ -2,4 +2,5 @@ from pathlib import Path
|
||||||
|
|
||||||
from webapp.worker.factory import create_app
|
from webapp.worker.factory import create_app
|
||||||
|
|
||||||
|
|
||||||
app = create_app(Path(__file__).parent)
|
app = create_app(Path(__file__).parent)
|
||||||
|
|
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from html5tagger import Builder, Document # type: ignore
|
from html5tagger import Builder, Document # type: ignore
|
||||||
|
|
||||||
|
|
||||||
class BaseRenderer:
|
class BaseRenderer:
|
||||||
def __init__(self, base_title: str):
|
def __init__(self, base_title: str):
|
||||||
self.base_title = base_title
|
self.base_title = base_title
|
||||||
|
|
|
@ -7,6 +7,7 @@ from pygments.token import ( # Error,; Generic,; Number,; Operator,
|
||||||
Token,
|
Token,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SanicCodeStyle(Style):
|
class SanicCodeStyle(Style):
|
||||||
styles = {
|
styles = {
|
||||||
Token: "#777",
|
Token: "#777",
|
||||||
|
|
|
@ -6,6 +6,7 @@ from typing import Generator
|
||||||
from html5tagger import Builder
|
from html5tagger import Builder
|
||||||
from sanic import Request
|
from sanic import Request
|
||||||
|
|
||||||
|
|
||||||
class BaseLayout:
|
class BaseLayout:
|
||||||
def __init__(self, builder: Builder):
|
def __init__(self, builder: Builder):
|
||||||
self.builder = builder
|
self.builder = builder
|
||||||
|
|
|
@ -3,6 +3,7 @@ from datetime import datetime
|
||||||
from html5tagger import Builder, E # type: ignore
|
from html5tagger import Builder, E # type: ignore
|
||||||
from sanic import Request
|
from sanic import Request
|
||||||
|
|
||||||
|
|
||||||
def do_footer(builder: Builder, request: Request) -> None:
|
def do_footer(builder: Builder, request: Request) -> None:
|
||||||
builder.footer(
|
builder.footer(
|
||||||
_pagination(request),
|
_pagination(request),
|
||||||
|
|
|
@ -3,6 +3,7 @@ from sanic import Request
|
||||||
|
|
||||||
from webapp.display.layouts.models import MenuItem
|
from webapp.display.layouts.models import MenuItem
|
||||||
|
|
||||||
|
|
||||||
def do_navbar(builder: Builder, request: Request) -> None:
|
def do_navbar(builder: Builder, request: Request) -> None:
|
||||||
navbar_items = [
|
navbar_items = [
|
||||||
_render_navbar_item(item, request)
|
_render_navbar_item(item, request)
|
||||||
|
|
|
@ -4,6 +4,7 @@ from sanic import Request
|
||||||
from webapp.display.layouts.models import MenuItem
|
from webapp.display.layouts.models import MenuItem
|
||||||
from webapp.display.text import slugify
|
from webapp.display.text import slugify
|
||||||
|
|
||||||
|
|
||||||
def do_sidebar(builder: Builder, request: Request) -> None:
|
def do_sidebar(builder: Builder, request: Request) -> None:
|
||||||
builder.a(class_="burger")(E.span().span().span().span())
|
builder.a(class_="burger")(E.span().span().span().span())
|
||||||
builder.aside(*_menu_items(request), class_="menu")
|
builder.aside(*_menu_items(request), class_="menu")
|
||||||
|
|
|
@ -8,6 +8,7 @@ from sanic import Request
|
||||||
|
|
||||||
from .base import BaseLayout
|
from .base import BaseLayout
|
||||||
|
|
||||||
|
|
||||||
class HomeLayout(BaseLayout):
|
class HomeLayout(BaseLayout):
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def layout(
|
def layout(
|
||||||
|
|
|
@ -9,6 +9,7 @@ from webapp.display.layouts.elements.sidebar import do_sidebar
|
||||||
|
|
||||||
from .base import BaseLayout
|
from .base import BaseLayout
|
||||||
|
|
||||||
|
|
||||||
class MainLayout(BaseLayout):
|
class MainLayout(BaseLayout):
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def layout(
|
def layout(
|
||||||
|
|
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from msgspec import Struct, field
|
from msgspec import Struct, field
|
||||||
|
|
||||||
|
|
||||||
class MenuItem(Struct, kw_only=False, omit_defaults=True):
|
class MenuItem(Struct, kw_only=False, omit_defaults=True):
|
||||||
label: str
|
label: str
|
||||||
path: str | None = None
|
path: str | None = None
|
||||||
|
|
|
@ -20,6 +20,7 @@ from .plugins.span import span
|
||||||
from .plugins.tabs import Tabs
|
from .plugins.tabs import Tabs
|
||||||
from .text import slugify
|
from .text import slugify
|
||||||
|
|
||||||
|
|
||||||
class DocsRenderer(HTMLRenderer):
|
class DocsRenderer(HTMLRenderer):
|
||||||
def block_code(self, code: str, info: str | None = None):
|
def block_code(self, code: str, info: str | None = None):
|
||||||
builder = Builder("Block")
|
builder = Builder("Block")
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from .page import Page
|
from .page import Page
|
||||||
from .renderer import PageRenderer
|
from .renderer import PageRenderer
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["Page", "PageRenderer"]
|
__all__ = ["Page", "PageRenderer"]
|
||||||
|
|
|
@ -15,6 +15,7 @@ from html5tagger import HTML, Builder, E # type: ignore
|
||||||
|
|
||||||
from ..markdown import render_markdown, slugify
|
from ..markdown import render_markdown, slugify
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class DocObject:
|
class DocObject:
|
||||||
name: str
|
name: str
|
||||||
|
|
|
@ -11,6 +11,7 @@ from ..layouts.main import MainLayout
|
||||||
from ..markdown import render_markdown
|
from ..markdown import render_markdown
|
||||||
from .docobject import organize_docobjects
|
from .docobject import organize_docobjects
|
||||||
|
|
||||||
|
|
||||||
_PAGE_CACHE: dict[
|
_PAGE_CACHE: dict[
|
||||||
str, dict[str, tuple[Page | None, Page | None, Page | None]]
|
str, dict[str, tuple[Page | None, Page | None, Page | None]]
|
||||||
] = {}
|
] = {}
|
||||||
|
|
|
@ -10,6 +10,7 @@ from webapp.display.base import BaseRenderer
|
||||||
from ..layouts.base import BaseLayout
|
from ..layouts.base import BaseLayout
|
||||||
from .page import Page
|
from .page import Page
|
||||||
|
|
||||||
|
|
||||||
class PageRenderer(BaseRenderer):
|
class PageRenderer(BaseRenderer):
|
||||||
def render(self, request: Request, language: str, path: str) -> Builder:
|
def render(self, request: Request, language: str, path: str) -> Builder:
|
||||||
builder = self.get_builder(
|
builder = self.get_builder(
|
||||||
|
|
|
@ -7,6 +7,7 @@ from mistune.block_parser import BlockParser
|
||||||
from mistune.core import BlockState
|
from mistune.core import BlockState
|
||||||
from mistune.directives import DirectivePlugin
|
from mistune.directives import DirectivePlugin
|
||||||
|
|
||||||
|
|
||||||
class Attributes(DirectivePlugin):
|
class Attributes(DirectivePlugin):
|
||||||
def __call__(self, directive, md):
|
def __call__(self, directive, md):
|
||||||
directive.register("attrs", self.parse)
|
directive.register("attrs", self.parse)
|
||||||
|
|
|
@ -8,6 +8,7 @@ from mistune.core import BlockState
|
||||||
from mistune.directives import DirectivePlugin, RSTDirective
|
from mistune.directives import DirectivePlugin, RSTDirective
|
||||||
from mistune.markdown import Markdown
|
from mistune.markdown import Markdown
|
||||||
|
|
||||||
|
|
||||||
class Column(DirectivePlugin):
|
class Column(DirectivePlugin):
|
||||||
def parse(
|
def parse(
|
||||||
self, block: BlockParser, m: Match, state: BlockState
|
self, block: BlockParser, m: Match, state: BlockState
|
||||||
|
|
|
@ -2,6 +2,7 @@ from mistune.core import BlockState
|
||||||
from mistune.directives import DirectivePlugin, RSTDirective
|
from mistune.directives import DirectivePlugin, RSTDirective
|
||||||
from mistune.markdown import Markdown
|
from mistune.markdown import Markdown
|
||||||
|
|
||||||
|
|
||||||
class Hook(DirectivePlugin):
|
class Hook(DirectivePlugin):
|
||||||
def __call__( # type: ignore
|
def __call__( # type: ignore
|
||||||
self, directive: RSTDirective, md: Markdown
|
self, directive: RSTDirective, md: Markdown
|
||||||
|
|
|
@ -10,6 +10,7 @@ from mistune.core import BlockState
|
||||||
from mistune.directives import DirectivePlugin, RSTDirective
|
from mistune.directives import DirectivePlugin, RSTDirective
|
||||||
from mistune.markdown import Markdown
|
from mistune.markdown import Markdown
|
||||||
|
|
||||||
|
|
||||||
class Mermaid(DirectivePlugin):
|
class Mermaid(DirectivePlugin):
|
||||||
def parse(
|
def parse(
|
||||||
self, block: BlockParser, m: Match, state: BlockState
|
self, block: BlockParser, m: Match, state: BlockState
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from html5tagger import HTML, E
|
from html5tagger import HTML, E
|
||||||
from mistune.directives import Admonition
|
from mistune.directives import Admonition
|
||||||
|
|
||||||
|
|
||||||
class Notification(Admonition):
|
class Notification(Admonition):
|
||||||
SUPPORTED_NAMES = {
|
SUPPORTED_NAMES = {
|
||||||
"success",
|
"success",
|
||||||
|
|
|
@ -2,6 +2,7 @@ import re
|
||||||
|
|
||||||
from mistune.markdown import Markdown
|
from mistune.markdown import Markdown
|
||||||
|
|
||||||
|
|
||||||
def parse_inline_span(inline, m: re.Match, state):
|
def parse_inline_span(inline, m: re.Match, state):
|
||||||
state.append_token(
|
state.append_token(
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,6 +8,7 @@ from mistune.core import BlockState
|
||||||
from mistune.directives import DirectivePlugin, RSTDirective
|
from mistune.directives import DirectivePlugin, RSTDirective
|
||||||
from mistune.markdown import Markdown
|
from mistune.markdown import Markdown
|
||||||
|
|
||||||
|
|
||||||
class Tabs(DirectivePlugin):
|
class Tabs(DirectivePlugin):
|
||||||
def parse(
|
def parse(
|
||||||
self, block: BlockParser, m: Match, state: BlockState
|
self, block: BlockParser, m: Match, state: BlockState
|
||||||
|
|
|
@ -9,6 +9,7 @@ from webapp.display.search.search import Searcher
|
||||||
from ..base import BaseRenderer
|
from ..base import BaseRenderer
|
||||||
from ..layouts.main import MainLayout
|
from ..layouts.main import MainLayout
|
||||||
|
|
||||||
|
|
||||||
class SearchRenderer(BaseRenderer):
|
class SearchRenderer(BaseRenderer):
|
||||||
def render(
|
def render(
|
||||||
self, request: Request, language: str, searcher: Searcher, full: bool
|
self, request: Request, language: str, searcher: Searcher, full: bool
|
||||||
|
|
|
@ -8,6 +8,7 @@ from msgspec import Struct
|
||||||
|
|
||||||
from webapp.display.page import Page
|
from webapp.display.page import Page
|
||||||
|
|
||||||
|
|
||||||
class Stemmer:
|
class Stemmer:
|
||||||
STOP_WORDS: ClassVar[set[str]] = set(
|
STOP_WORDS: ClassVar[set[str]] = set(
|
||||||
"a about above after again against all am an and any are aren't as at be because been before being below between both but by can't cannot could couldn't did didn't do does doesn't doing don't down during each few for from further had hadn't has hasn't have haven't having he he'd he'll he's her here here's hers herself him himself his how how's i i'd i'll i'm i've if in into is isn't it it's its itself let's me more most mustn't my myself no nor not of off on once only or other ought our ours ourselves out over own same shan't she she'd she'll she's should shouldn't so some such than that that's the their theirs them themselves then there there's these they they'd they'll they're they've this those through to too under until up very was wasn't we we'd we'll we're we've were weren't what what's when when's where where's which while who who's whom why why's with won't would wouldn't you you'd you'll you're you've your yours yourself yourselves".split() # noqa: E501
|
"a about above after again against all am an and any are aren't as at be because been before being below between both but by can't cannot could couldn't did didn't do does doesn't doing don't down during each few for from further had hadn't has hasn't have haven't having he he'd he'll he's her here here's hers herself him himself his how how's i i'd i'll i'm i've if in into is isn't it it's its itself let's me more most mustn't my myself no nor not of off on once only or other ought our ours ourselves out over own same shan't she she'd she'll she's should shouldn't so some such than that that's the their theirs them themselves then there there's these they they'd they'll they're they've this those through to too under until up very was wasn't we we'd we'll we're we've were weren't what what's when when's where where's which while who who's whom why why's with won't would wouldn't you you'd you'll you're you've your yours yourself yourselves".split() # noqa: E501
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
SLUGIFY_PATTERN = re.compile(r"[^a-zA-Z0-9-]")
|
SLUGIFY_PATTERN = re.compile(r"[^a-zA-Z0-9-]")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ from webapp.display.page import Page
|
||||||
from webapp.display.search.renderer import SearchRenderer
|
from webapp.display.search.renderer import SearchRenderer
|
||||||
from webapp.display.search.search import Document, Searcher, Stemmer
|
from webapp.display.search.search import Document, Searcher, Stemmer
|
||||||
|
|
||||||
|
|
||||||
bp = Blueprint("search", url_prefix="/<language>/search")
|
bp = Blueprint("search", url_prefix="/<language>/search")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,4 +2,5 @@ from sanic import Blueprint
|
||||||
|
|
||||||
from .search import bp as search_bp
|
from .search import bp as search_bp
|
||||||
|
|
||||||
|
|
||||||
bp = Blueprint.group(search_bp)
|
bp = Blueprint.group(search_bp)
|
||||||
|
|
|
@ -4,6 +4,7 @@ from msgspec import yaml
|
||||||
|
|
||||||
from webapp.display.layouts.models import GeneralConfig, MenuItem
|
from webapp.display.layouts.models import GeneralConfig, MenuItem
|
||||||
|
|
||||||
|
|
||||||
def load_menu(path: Path) -> list[MenuItem]:
|
def load_menu(path: Path) -> list[MenuItem]:
|
||||||
loaded = yaml.decode(path.read_bytes(), type=dict[str, list[MenuItem]])
|
loaded = yaml.decode(path.read_bytes(), type=dict[str, list[MenuItem]])
|
||||||
return loaded["root"]
|
return loaded["root"]
|
||||||
|
|
|
@ -9,6 +9,7 @@ from webapp.worker.config import load_config, load_menu
|
||||||
from webapp.worker.reload import setup_livereload
|
from webapp.worker.reload import setup_livereload
|
||||||
from webapp.worker.style import setup_style
|
from webapp.worker.style import setup_style
|
||||||
|
|
||||||
|
|
||||||
def _compile_sidebar_order(items: list[MenuItem]) -> list[str]:
|
def _compile_sidebar_order(items: list[MenuItem]) -> list[str]:
|
||||||
order = []
|
order = []
|
||||||
for item in items:
|
for item in items:
|
||||||
|
|
|
@ -8,6 +8,7 @@ import ujson
|
||||||
|
|
||||||
from sanic import Request, Sanic, Websocket
|
from sanic import Request, Sanic, Websocket
|
||||||
|
|
||||||
|
|
||||||
def setup_livereload(app: Sanic) -> None:
|
def setup_livereload(app: Sanic) -> None:
|
||||||
@app.main_process_start
|
@app.main_process_start
|
||||||
async def main_process_start(app: Sanic):
|
async def main_process_start(app: Sanic):
|
||||||
|
|
|
@ -6,6 +6,7 @@ from sass import compile as compile_scss
|
||||||
|
|
||||||
from webapp.display.code_style import SanicCodeStyle
|
from webapp.display.code_style import SanicCodeStyle
|
||||||
|
|
||||||
|
|
||||||
def setup_style(app: Sanic) -> None:
|
def setup_style(app: Sanic) -> None:
|
||||||
index = app.config.STYLE_DIR / "index.scss"
|
index = app.config.STYLE_DIR / "index.scss"
|
||||||
style_output = app.config.PUBLIC_DIR / "assets" / "style.css"
|
style_output = app.config.PUBLIC_DIR / "assets" / "style.css"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user