Skip to content

Commit

Permalink
A lot of lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MartenBE committed Sep 11, 2024
1 parent 5edc6de commit 6f9b175
Show file tree
Hide file tree
Showing 16 changed files with 232 additions and 212 deletions.
50 changes: 43 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

## Features

- Build static HTML files from Markdown files.
- Turn a single Markdown file into a HTML slideshow.
- Turn a folder with Markdown files into a collection of HTML slideshows.
- Publish your slideshow(s) anywhere that static files can be served.
- Preview your site as you work, thanks to [python-livereload](https://pypi.org/project/livereload/).
- Use custom favicons, CSS themes, templates, ... if desired.
- And more!
- Build static HTML files from Markdown files.
- Turn a single Markdown file into a HTML slideshow.
- Turn a folder with Markdown files into a collection of HTML slideshows.
- Publish your slideshow(s) anywhere that static files can be served.
- Preview your site as you work, thanks to [python-livereload](https://pypi.org/project/livereload/).
- Use custom favicons, CSS themes, templates, ... if desired.
- And more!

## Example

Expand Down Expand Up @@ -53,3 +53,39 @@ mkslides-reveal serve docs/
```bash
mkslides-reveal serve test.md
```

## Configuration

Just create a `mkslides.yml`. All options are optional, you only have to add what you want to change to `mkslides.yml`.

Here's an example:

```yml
index:
title: example-title
favicon: ./example-index-favicon.ico
theme: example-index-theme.css
slides:
favicon: ./example-slides-favicon.ico
theme: example-slides-theme.css
highlight_theme: example-slides-highlight-theme.css
separator: ^\s*---\s*$
separator_vertical: ^\s*-v-\s*$
separator_notes: "^Notes?:"
separator_charset: utf-8
reveal.js:
height: 1080
width: 1920
transition: fade
plugins:
- name: RevealMermaid
extra_javascript:
- https://cdn.jsdelivr.net/npm/reveal.js-mermaid-plugin/plugin/mermaid/mermaid.min.js
- extra_javascript:
- https://cdn.jsdelivr.net/npm/reveal-plantuml/dist/reveal-plantuml.min.js
```
- `favicon`and `theme`, can also be configured as an URL, e.g. `https://example.org/theme.css`.
- `theme` can also be configured as a [Reveal.js built-in theme](https://revealjs.com/themes/), e.g. `black`, `white`, `league`, `solarized`, `dracula`, ... .
- `highlight_theme` can also be configured as a [highlight.js built-in theme](https://highlightjs.org/examples), e.g. `monokai`, `obsidian`, `tokyo-night-dark`, `vs`, ... .
- `reveal.js` can contain all [Reveal.js options](https://revealjs.com/config/).
100 changes: 28 additions & 72 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 22 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ click = "^8.1.7"

[tool.poetry.group.dev.dependencies]
bumpver = "^2023.1129"
black = "^24.8.0"
mypy = "^1.11.2"
types-pyyaml = "^6.0.12.20240808"
ruff = "^0.6.4"


[tool.poetry.group.test.dependencies]
Expand Down Expand Up @@ -50,3 +50,24 @@ push = true
[tool.bumpver.file_patterns]
"src/mkslides_reveal/__init__.py" = ['^__version__ = "{version}"']
"pyproject.toml" = ['^version = "{version}"', '^current_version = "{version}"']

[tool.ruff.lint]
ignore = [
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D103", # Missing docstring in public function
"D102", # Missing docstring in public method
"D104", # Missing docstring in public package"
"D107", # Missing docstring in `__init__`
"E501", # Line too long
"FA102", # Missing `from __future__ import annotations`, but uses PEP 585 collection
"G004", # Logging statement uses f-string"
"PLR0913", # Too many arguments in function definition
"RET504", # Unnecessary assignment to `...` before `return` statement
"S101", # Use of `assert` detected
"TD002", # Missing author in TODO; try: `# TODO(<author_name>): ...` or `# TODO @<author_name>: ...`
"TD003", # Missing issue link on the line following this TODO

]
select = ["ALL"]
2 changes: 0 additions & 2 deletions src/mkslides_reveal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
#!/usr/bin/env python

__version__ = "0.1.14"
32 changes: 12 additions & 20 deletions src/mkslides_reveal/__main__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
#!/usr/bin/env python

import shutil
import click
import livereload
import logging
import shutil
import tempfile
from pathlib import Path
from urllib.parse import urlparse

import click
import livereload
from livereload.handlers import LiveReloadHandler
from pathlib import Path
from rich.logging import RichHandler
from urllib.parse import urlparse

from .config import Config
from .constants import (
EXPECTED_CONFIG_LOCATION,
DEFAULT_OUTPUT_DIR,
VERSION,
REVEALJS_VERSION,
EXPECTED_CONFIG_LOCATION,
HIGHLIGHTJS_THEMES_VERSION,
REVEALJS_VERSION,
VERSION,
)
from .markupgenerator import MarkupGenerator


logger = logging.getLogger()
logger.setLevel("DEBUG")
logger.addHandler(RichHandler(show_path=False))
Expand Down Expand Up @@ -54,8 +51,7 @@
"",
)
def cli() -> None:
"MkSlides-Reveal - Slides with Markdown using the power of Reveal.js."
pass
"""MkSlides-Reveal - Slides with Markdown using the power of Reveal.js."""


def read_config(config_location: str) -> Config:
Expand Down Expand Up @@ -100,12 +96,10 @@ def generate(config_file, input_path: Path, output_directory: Path) -> None:
default=DEFAULT_OUTPUT_DIR,
)
def build(files, config_file, site_dir) -> None:
"""
Build the MkDocs documentation.
"""Build the MkDocs documentation.
FILENAME|PATH is the path to the Markdown file, or the directory containing Markdown files.
"""

logger.info("Command: build")

input_path = Path(files).resolve(strict=True)
Expand Down Expand Up @@ -161,12 +155,10 @@ def serve(
watch_slides_template,
config_file,
) -> None:
"""
Run the builtin development server.
"""Run the builtin development server.
FILENAME|PATH is the path to the Markdown file, or the directory containing Markdown files.
"""

logger.info("Command: serve")

input_path = Path(files).resolve(strict=True)
Expand All @@ -190,7 +182,7 @@ def reload() -> None:

watched_paths = [
files,
config_file, # TODO reload config
config_file, # TODO: reload config
]

if watch_index_theme:
Expand Down
8 changes: 3 additions & 5 deletions src/mkslides_reveal/config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import importlib
import logging
import yaml

from pathlib import Path

from .constants import DEFAULT_CONFIG_RESOURCE
import yaml

from .constants import DEFAULT_CONFIG_RESOURCE

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -72,7 +70,7 @@ def merge_config_from_file(self, config_path: Path) -> None:
def merge_config_from_dict(self, new_config: dict) -> None:
self.__config = self.__recursive_merge(self.__config, new_config)

logger.info(f"Config merged from dict")
logger.info("Config merged from dict")
logger.info(f"Config: {self.__config}")

def __get(self, *keys) -> str | dict | list | None:
Expand Down
7 changes: 4 additions & 3 deletions src/mkslides_reveal/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import re
from importlib import metadata, resources

from importlib import resources, metadata
from jinja2 import Environment, FileSystemLoader, PackageLoader, select_autoescape

MD_LINK_REGEX = re.compile(
Expand Down Expand Up @@ -51,11 +51,12 @@
HIGHLIGHTJS_THEMES_RESOURCE = HIGHLIGHTJS_RESOURCE.joinpath("build", "styles")

DEFAULT_JINJA2_ENVIRONMENT = Environment(
loader=PackageLoader("assets"), autoescape=select_autoescape()
loader=PackageLoader("assets"),
autoescape=select_autoescape(),
)
DEFAULT_INDEX_TEMPLATE = DEFAULT_JINJA2_ENVIRONMENT.get_template("index.html.jinja")
DEFAULT_SLIDESHOW_TEMPLATE = DEFAULT_JINJA2_ENVIRONMENT.get_template(
"slideshow.html.jinja"
"slideshow.html.jinja",
)
LOCAL_JINJA2_ENVIRONMENT = Environment(loader=FileSystemLoader("."))

Expand Down
Loading

0 comments on commit 6f9b175

Please sign in to comment.