From 6c27c6cdb9feff6ded293b3673e8ae66155f6bed Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Sat, 18 Feb 2023 16:02:07 -0600 Subject: modify build config and add more test packages --- AUTHORS | 4 - ChangeLog | 189 ----------------------------------------- README.md | 34 ++++---- pyproject.toml | 28 +++++- pyssg.xyz/src/blog/toc_test.md | 31 +++++++ requirements.txt | 3 +- requirements_dev.txt | 6 ++ setup.cfg | 32 ++++++- src/pyssg/md_parser.py | 2 + src/pyssg/page.py | 4 + src/pyssg/py.typed | 0 11 files changed, 116 insertions(+), 217 deletions(-) delete mode 100644 AUTHORS delete mode 100644 ChangeLog create mode 100644 pyssg.xyz/src/blog/toc_test.md create mode 100644 requirements_dev.txt create mode 100644 src/pyssg/py.typed diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 1b11bba..0000000 --- a/AUTHORS +++ /dev/null @@ -1,4 +0,0 @@ -David Luevano Alvarado <55825613+luevano@users.noreply.github.com> -David Luevano Alvarado -David Luevano Alvarado -El LM diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index 29ff8aa..0000000 --- a/ChangeLog +++ /dev/null @@ -1,189 +0,0 @@ -CHANGES -======= - -v0.8.2 ------- - -* remove unnecessary variables for page object - -v0.8.1 ------- - -* add more files, fixed bugs related to multiple documents in yaml config -* add new files for pyssg.xyz, add multiple document support -* add pyssg.xyz configs and templates -* update pyssg.xyz site files -* fix for twine upload to pypi - -v0.8.0 ------- - -* refactor code and update readme -* remove force feature, unnecessary complexity -* refactor code, small bug fixing and changes -* refactor code, fix config checker and new files for pyssg.xyz -* add extra configuration for more control, add pyssg.xyz example -* forgot to change extension on argparser help text -* migrate from INI to YAML, breaks compatibility -* change syntax for accessing config variable -* refactor database entries into its own class -* refactor code and fix type checks -* change python/twine command for the build command - -v0.7.3 ------- - -* replace uncompatible highlighter/marker - -v0.7.2 ------- - -* Add new extensions for ^ and ~ syntax - -v0.7.1 ------- - -* add proper var expansion from config file - -v0.7.0 ------- - -* add checksum checking for mod files instead of timestamp - -v0.6.2 ------- - -* mayor bugfix in the database writer -* minor refactoring - -v0.6.1 ------- - -* add meaningful error messages when missing mandatory metadata -* add logging to builder, md\_parser and page, and minor code refactor -* minor debug fix for database -* fix db write bug missing newline, minor refactor -* fix pyssg and database errors -* add logging to database, discovery and pyssg -* add typing to formatter -* add debug flag, minor fix in readme -* add initial logging capabilities -* add build and upload command, modified readme - -v0.6.0 ------- - -* refactor config handler and more -* add default configuration to resources -* refactor argument parser -* update requirements -* The bullets did not have checkboxes in the To be added section -* A header was wrong -* A little documentation added to avoid mistakes by new users -* kek xd rofl lmao forgot to save a file:), now actually a quick fix -* quick fix on random uppercased letters -* Delete pyssgrc -* fix bug on new extensions -* add new extensions -* fix bug on prev/next objects of page -* add config to read first pyssgrc and then to the xdg directory -* fix bug on image\_url -* fix another bug -* fix bug - -v0.5.3 ------- - -* refactor code and add image\_url parsing - -v0.5.2 ------- - -* fix minor bug on rss template - -v0.5.1 ------- - -* minor fix on dirs discovery - -v0.5.0 ------- - -* add ability to copy basic template files -* move plt dir to be included in data -* refactor and add support for jinija -* just include changelog - -v0.4.1 ------- - -* fix m\_datetime bug -* add tags inside article footer instead of separate html element - -v0.4.0 ------- - -* fix bug -* fix bug -* fix bug -* add sitemap support - -v0.3.1 ------- - -* fix readme links -* add tags as categories -* add content:encoded tag in rss and update readme - -v0.3.0 ------- - -* add better version printing -* fix timezone -* fix missing ref to obj -* fix bad method call -* ... literally 3 commits to fix a missing obj -* ACTUALLY add missing config obj lol -* fix missing config obj -* add rss support - -v0.2.4 ------- - -* lol wrong src and dst variables read -* fix error on parsing config file -* finally fix argparse error, questionmark -* checking argparse errors -* fix missing import - -v0.2.3 ------- - -* add more configuration options and refactor its parsing - -v0.2.2 ------- - -* fix sorting of pages and update default templates - -v0.2.1 ------- - -* fix required base url and tag header substitution - -v0.2.0 ------- - -* clean up and update readme -* refactor code and finish basic features - -v0.1.0 ------- - -* refactor code and almost finish main functionality -* semiworking program, still very alpha -* Add working file discovery and destination file structure creation -* initial template creation, barebones arg parser -* Prepare barebones package info -* Update readme -* Initial commit diff --git a/README.md b/README.md index 79db720..f971860 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ This program uses the base [`markdown` syntax](https://daringfireball.net/projec - Meta-Data. - Sane Lists. - SmartyPants. -- Table of Contents. +- Table of Contents. (With defaults as specified [here](https://python-markdown.github.io/extensions/toc/)) - WikiLinks. - [yafg - Yet Another Figure Generator](https://git.sr.ht/~ferruck/yafg) - [Markdown Checklist](https://github.com/FND/markdown-checklist) @@ -137,25 +137,25 @@ fmt: list_sep_date: "%B %Y" dirs: /: # root "dir_path", whatever is sitting directly under "src" - cfg: - plt: "page.html" - # the template can be specified instead of just True/False, a default template will used - tags: False - index: True - rss: True - sitemap: True - exclude_dirs: ["articles", "blog"] # optional; list of subdirectories to exclude when parsing the / dir_path + cfg: + plt: "page.html" + # the template can be specified instead of just True/False, a default template will used + tags: False + index: True + rss: True + sitemap: True + exclude_dirs: ["articles", "blog"] # optional; list of subdirectories to exclude when parsing the / dir_path # below are other example "dir_paths", can be named anything, only the / (above) is mandatory articles: cfg: - plt: "page.html" - tags: True - index: True - rss: True - sitemap: True + plt: "page.html" + tags: True + index: True + rss: True + sitemap: True blog: cfg: - # ... + # ... ... ``` @@ -178,7 +178,7 @@ sitemap_run_date: # date the program was run, formatted with 'fmt.sitemap_date' ... ``` -You can add any other option/section that you can later use in the Jinja templates via the exposed config object. URL's shouldn't have the trailing slash `/` +You can add any other option/section that you can later use in the Jinja templates via the exposed config object. URL's shouldn't have the trailing slash `/`. ## Available Jinja variables @@ -193,6 +193,8 @@ These variables are exposed to use within the templates. The below list is displ - `lang` (`str`): page language, used for the general `html` tag `lang` attribute. - `summary` (`str`): summary of the page, as specified in the `*.md` file. - `content` (`str`): actual content of the page, this is the `html`. + - `toc` (`str`): table of contents as taken from `md.toc`. + - `toc_tokens` (`list(dict)`): table of contents tokens as taken from `md.toc_tokens`. - `cdatetime` (`datetime.datetime`): creation datetime object of the page. - `cdate` (`method`): method thtat takes the name of the `fmt.FMT` and applies it to the `cdatetime` object. - `cdate_rss` (`str`): formatted `cdatetime` as required by rss. diff --git a/pyproject.toml b/pyproject.toml index e74c9ec..30773d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,26 @@ [build-system] -requires = [ - "setuptools>=42", - "wheel" +requires = ["pbr>=5.7.0", "setuptools>=36.6.0"] +build-backend = "pbr.build" + +[tool.pytest.ini_options] +addopts = "--cov-report term-missing --cov=pyssg" +testpaths = [ + "tests", ] -build-backend = "setuptools.build_meta" +env = [ + "PYMDVAR_TEST_1=1" +] + +[tool.mypy] +mypy_path = "src" +check_untyped_defs = true +disallow_any_generics = true +ignore_missing_imports = true +no_implicit_optional = true +show_error_codes = true +strict_equality = true +warn_redundant_casts = true +warn_return_any = true +warn_unreachable = true +warn_unused_configs = true +no_implicit_reexport = true diff --git a/pyssg.xyz/src/blog/toc_test.md b/pyssg.xyz/src/blog/toc_test.md new file mode 100644 index 0000000..43ef7ad --- /dev/null +++ b/pyssg.xyz/src/blog/toc_test.md @@ -0,0 +1,31 @@ +title: Table of contents test +author: David Luévano +lang: en +summary: This is just a post used for testing. +tags: test + english + short + update + +This is just a table of content test + +# Table of contents +[TOC] + +# Hello + +Anyone there? + +## No + +Nobody. + +# Test? + +Don't know how many of these I'll "test". + +## Second + +### Test 2? + +Last one diff --git a/requirements.txt b/requirements.txt index 9192da2..6078047 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,6 @@ Markdown>=3.4.1 markdown-checklist>=0.4.4 MarkupSafe>=2.1.1 yafg>=0.3 -pymdown-extensions>=9.9 +pymdown-extensions>=9.9.2 +pymdvar>=1.0.3 PyYAML>=6.0 diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..87baa83 --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,6 @@ +pytest>=7.2.1 +pytest-cov>=4.0.0 +pytest-env>=0.8.1 +mypy>=1.0.0 +flake8>=6.0.0 +types-Markdown>=3.4.2.4 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index f661287..bbd073e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,14 +2,27 @@ name = pyssg author = David Luevano Alvarado author_email = david@luevano.xyz -summary = A Static Site Generator using markdown files +summary = A Static Site Generator using markdown files. description_file = README.md license = GPLv3 home_page = https://github.com/luevano/pyssg classifiers = - Programming Language :: Python :: 3 License :: OSI Approved :: GNU General Public License v3 (GPLv3) Operating System :: Unix + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3 :: Only + Topic :: Communications :: Email :: Filters + Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries + Topic :: Internet :: WWW/HTTP :: Site Management + Topic :: Software Development :: Documentation + Topic :: Software Development :: Libraries :: Python Modules + Topic :: Text Processing :: Filters Topic :: Text Processing :: Markup :: HTML Topic :: Text Processing :: Markup :: Markdown keywords = @@ -18,6 +31,7 @@ keywords = site generator markdown + website [files] packages = @@ -34,7 +48,19 @@ console_scripts = package_dir = = src packages = find: -include_package_data=True +include_package_data = True [options.packages.find] where = src + +[options.package_data] +pymdvar = py.typed + +[flake8] +max-line-length = 160 +per-file-ignores = + __init__.py: W292 + +[pbr] +skip_authors = True +skip_changelog = True \ No newline at end of file diff --git a/src/pyssg/md_parser.py b/src/pyssg/md_parser.py index 8751035..07c62f8 100644 --- a/src/pyssg/md_parser.py +++ b/src/pyssg/md_parser.py @@ -71,6 +71,8 @@ class MDParser: self.db.e[f].ctimestamp, self.db.e[f].mtimestamp, content, + self.md.toc, # type: ignore + self.md.toc_tokens, # type: ignore self.md.Meta, # type: ignore self.config, self.dir_config) diff --git a/src/pyssg/page.py b/src/pyssg/page.py index 85a6a47..19c92f9 100644 --- a/src/pyssg/page.py +++ b/src/pyssg/page.py @@ -12,6 +12,8 @@ class Page: ctime: float, mtime: float, html: str, + toc: str, + toc_tokens: list[str], meta: dict, config: dict, dir_config: dict) -> None: @@ -21,6 +23,8 @@ class Page: self.ctimestamp: float = ctime self.mtimestamp: float = mtime self.content: str = html + self.toc: str = toc + self.toc_tokens: list[str] = toc_tokens self.meta: dict = meta self.config: dict = config self.dir_config: dict = dir_config diff --git a/src/pyssg/py.typed b/src/pyssg/py.typed new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3-54-g00ecf