This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from pathlib import Path | |
def read_files(): | |
return list(Path("staging_docs/sections/blog/posts/").glob("*.md")) | |
def fix_blog_posts(): | |
""" | |
Problems: | |
* add heading zero to filenames missing it: yyyy-mm-d | |
* delete "- date:" lines from frontmatter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import typing as t | |
from dataclasses import dataclass, is_dataclass | |
# not strictly necessary, but makes sense | |
T = t.TypeVar("T") # https://mypy.readthedocs.io/en/stable/generics.html | |
class ValidationError(ValueError): | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
# https://gist.github.com/zaiste/77a946bbba73f5c4d33f3106a494e6cd | |
FILENAME="CHANGES" | |
pandoc "$FILENAME.rst" -f rst -t markdown -o "$FILENAME.md" | |
# quotes: \"hupper\" -> "hupper" | |
sed -i "$FILENAME.md" -e 's/\\\("[a-zA-Z_-]*\)\\"/\1"/g' | |
# github: `4976`{.interpreted-text role="github"} -> [4976](https://github.../issues/4976) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 1. create structure | |
mkdir -p \ | |
staging_docs/{admin,user,dev}/{guides,tutorials,learn} \ | |
staging_docs/reference | |
cp -r docs tmp_docs | |
# 2. convert to rst->markdown (optional) | |
pip install rst-to-myst[sphinx] | |
find tmp_docs -name '*.rst' -exec rst2myst convert --replace-files {} ';' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
from io import TextIOWrapper | |
from typing import Callable, TypeAlias | |
FileParser: TypeAlias = Callable[[TextIOWrapper], dict[str, str]] | |
def load_data(obj, file_parser: FileParser, extensions: tuple[str, ...], **kwargs): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dynaconf import Dynaconf | |
settings = Dynaconf( | |
envvar_prefix="DYNACONF", | |
settings_file="settings.toml", | |
environments=True, | |
) |