Skip to content

Commit 3f3deb9

Browse files
Dev experience stuff (#10)
1 parent 8868f7f commit 3f3deb9

13 files changed

Lines changed: 285 additions & 19 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/python
3+
{
4+
"name": "Python 3",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "mcr.microsoft.com/devcontainers/python:0-3.10",
7+
"features": {
8+
"ghcr.io/devcontainers/features/github-cli:1": {},
9+
"ghcr.io/devcontainers-contrib/features/pipx-package:1": {},
10+
"ghcr.io/devcontainers-contrib/features/poetry:2": {},
11+
"ghcr.io/devcontainers-contrib/features/pre-commit:2": {}
12+
},
13+
// Features to add to the dev container. More info: https://containers.dev/features.
14+
// "features": {},
15+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
16+
// "forwardPorts": [],
17+
"forwardPorts": [
18+
8000
19+
],
20+
"portsAttributes": {
21+
"8000": {
22+
"label": "mkdocs serve",
23+
"onAutoForward": "notify"
24+
}
25+
},
26+
// Use 'postCreateCommand' to run commands after the container is created.
27+
// "postCreateCommand": "pip3 install --user -r requirements.txt",
28+
"postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder} && pre-commit && poetry install",
29+
"customizations": {
30+
"vscode": {
31+
"extensions": [
32+
"EditorConfig.EditorConfig",
33+
"GitHub.vscode-pull-request-github",
34+
"yzhang.markdown-all-in-one",
35+
"ms-vscode-remote.vscode-remote-extensionpack"
36+
]
37+
}
38+
}
39+
// Configure tool-specific properties.
40+
// "customizations": {},
41+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
42+
// "remoteUser": "root"
43+
}

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 88

.github/workflows/workflow.pr.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,15 @@ jobs:
3030
- name: Install dependencies
3131
run: poetry install --only=dev
3232

33+
- name: Check imports sort
34+
run: poetry run isort --check-only .
35+
3336
- name: Check formatting
3437
run: poetry run black --check .
3538

39+
- name: Check formatting
40+
run: poetry run flake8 --count .
41+
3642
test:
3743
name: Test
3844
needs: lint

.pre-commit-config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 23.1.0
4+
hooks:
5+
- id: black
6+
- repo: https://github.com/PyCQA/isort
7+
rev: 5.12.0
8+
hooks:
9+
- id: isort
10+
- repo: https://github.com/pycqa/flake8
11+
rev: 6.0.0
12+
hooks:
13+
- id: flake8

dev.build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
#!/bin/bash
22

33
rm -rf dist && rm -rf build && rm -rf site && rm -rf *.egg-info
4+
5+
poetry run isort .
46
poetry run black .
7+
poetry run flake8 --count .
8+
59
poetry build
10+
611
pip uninstall -y mkdocs_file_filter_plugin
712
pip install dist/mkdocs_file_filter_plugin-*.tar.gz
13+
14+
poetry run mkdocs serve --verbose

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
INHERIT: mkdocs.base.yml
22

3-
dev_addr: 127.0.0.1:1357
3+
#! dev_addr: 127.0.0.1:1357
44

55
plugins:
66
- search

mkdocs_file_filter_plugin/external_config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import os
22
import pathlib
3+
34
import yaml
4-
from yaml_env_tag import construct_env_tag
5-
from schema import Optional, Schema, SchemaError
65
from mkdocs.exceptions import PluginError
6+
from schema import Optional, Schema, SchemaError
7+
from yaml_env_tag import construct_env_tag
8+
79
from . import util as LOG
810

911

mkdocs_file_filter_plugin/judger.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import os
21
import fnmatch
3-
import re
2+
import os
43
import pathlib
4+
import re
5+
56
import igittigitt
6-
from .plugin_config import PluginConfig
7+
from mkdocs.config.defaults import MkDocsConfig
78
from mkdocs.structure.files import File as MkDocsFile
89
from mkdocs.structure.pages import Page as MkDocsPage
9-
from mkdocs.config.defaults import MkDocsConfig
10+
11+
from .plugin_config import PluginConfig
1012

1113

1214
class Judger:
@@ -52,7 +54,7 @@ def evaluate(self, file: MkDocsFile):
5254
return True, "no rule"
5355

5456
def __path_fix(self, src_path, abs_src_path):
55-
if os.sep is not "/":
57+
if os.sep != "/":
5658
src_path = src_path.replace(os.sep, "/")
5759
abs_src_path = abs_src_path.replace(os.sep, "/")
5860
return src_path, abs_src_path

mkdocs_file_filter_plugin/plugin.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import pathlib
2-
from mkdocs.plugins import BasePlugin as MkDocsPlugin
2+
33
from mkdocs.config.defaults import MkDocsConfig
4-
from mkdocs.structure.files import Files as MkDocsFiles
54
from mkdocs.exceptions import PluginError as MkDocsPluginError
5+
from mkdocs.plugins import BasePlugin as MkDocsPlugin
6+
from mkdocs.structure.files import Files as MkDocsFiles
7+
68
from . import util as LOG
7-
from .judger import Judger
89
from .external_config import ExternalConfig
10+
from .judger import Judger
911
from .plugin_config import PluginConfig
1012

1113

@@ -19,7 +21,7 @@ def on_config(self, config: MkDocsConfig):
1921
file_filter_config = external_config.load(self.config.config)
2022

2123
for k in self.config.keys():
22-
if k is not "config":
24+
if k != "config":
2325
self.config[k] = file_filter_config.get(k, self.config[k])
2426

2527
config.watch.append(pathlib.Path(self.config.config))

mkdocs_file_filter_plugin/plugin_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from mkdocs.config.base import Config as MkDocsConfigBase
21
import mkdocs.config.config_options as MkDocsConfigOptions
2+
from mkdocs.config.base import Config as MkDocsConfigBase
33

44

55
class PluginConfig(MkDocsConfigBase):

0 commit comments

Comments
 (0)