Skip to content

Commit

Permalink
Move config schema to Mkdocs > 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts committed Jul 24, 2023
1 parent bd565ae commit e8014da
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
30 changes: 30 additions & 0 deletions mkdocs_rss_plugin/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#! python3 # noqa: E265

# ############################################################################
# ########## Libraries #############
# ##################################


# 3rd party
from mkdocs.config import config_options
from mkdocs.config.base import Config


# ############################################################################
# ########## Classes ###############
# ##################################
class RssPluginConfig(Config):
"""Configuration for RSS plugin for Mkdocs."""

abstract_chars_count = config_options.Type(int, default=160)
abstract_delimiter = config_options.Type(str, default="<!-- more -->")
categories = config_options.Type(list, default=None)
comments_path = config_options.Type(str, default=None)
date_from_meta = config_options.Type(dict, default=None)
enabled = config_options.Type(bool, default=True)
feed_ttl = config_options.Type(int, default=1440)
image = config_options.Type(str, default=None)
length = config_options.Type(int, default=20)
match_path = config_options.Type(str, default=".*")
pretty_print = config_options.Type(bool, default=False)
url_parameters = config_options.Type(dict, default=None)
25 changes: 5 additions & 20 deletions mkdocs_rss_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
from mkdocs.utils import get_build_timestamp

# package modules
from .__about__ import __title__, __uri__, __version__
from .customtypes import PageInformation
from .util import Util
from mkdocs_rss_plugin.__about__ import __title__, __uri__, __version__
from mkdocs_rss_plugin.config import RssPluginConfig
from mkdocs_rss_plugin.customtypes import PageInformation
from mkdocs_rss_plugin.util import Util

# ############################################################################
# ########## Globals #############
Expand All @@ -42,25 +43,9 @@
# ##################################


class GitRssPlugin(BasePlugin):
class GitRssPlugin(BasePlugin[RssPluginConfig]):
"""Main class for MkDocs plugin."""

config_scheme = (
("abstract_chars_count", config_options.Type(int, default=160)),
("abstract_delimiter", config_options.Type(str, default="<!-- more -->")),
("categories", config_options.Type(list, default=None)),
("comments_path", config_options.Type(str, default=None)),
("date_from_meta", config_options.Type(dict, default=None)),
("enabled", config_options.Type(bool, default=True)),
("feed_ttl", config_options.Type(int, default=1440)),
("image", config_options.Type(str, default=None)),
("length", config_options.Type(int, default=20)),
("match_path", config_options.Type(str, default=".*")),
("pretty_print", config_options.Type(bool, default=False)),
("url_parameters", config_options.Type(dict, default=None)),
("use_git", config_options.Type(bool, default=True)),
)

def __init__(self):
"""Instanciation."""
# dates source
Expand Down

0 comments on commit e8014da

Please sign in to comment.