forked from lessonomicon/mccole
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
version: 0.2.5
- Loading branch information
Showing
6 changed files
with
70 additions
and
13 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"""Report site stats.""" | ||
|
||
import argparse | ||
from prettytable import PrettyTable | ||
|
||
from .util import MD_LINK_DEF, SUFFIXES, SUFFIXES_SRC, find_files, find_key_defs | ||
|
||
|
||
TABLE_FMT = { | ||
"stat": "l", | ||
"value": "r", | ||
} | ||
|
||
|
||
def stats(opt): | ||
"""Main driver.""" | ||
table = PrettyTable(field_names=TABLE_FMT.keys()) | ||
for k, v in TABLE_FMT.items(): | ||
table.align[k] = v | ||
|
||
files = find_files(opt, set(["bin", opt.out])) | ||
table.add_row(("bibliography entries", len(find_key_defs(files, "bibliography")))) | ||
table.add_row(("glossary entries", len(find_key_defs(files, "glossary")))) | ||
table.add_row(("link definitions", len(find_markdown_link_defs(files)))) | ||
|
||
print(table) | ||
|
||
|
||
def find_markdown_link_defs(files): | ||
"""Collect Markdown link key definnitions.""" | ||
found = set() | ||
for filepath, content in files.items(): | ||
if filepath.suffix == ".md": | ||
for link in MD_LINK_DEF.finditer(content): | ||
found.add(link[0]) | ||
return found | ||
|
||
|
||
def parse_args(parser): | ||
"""Parse command-line arguments.""" | ||
parser.add_argument("--out", type=str, default="docs", help="output directory") | ||
parser.add_argument("--root", type=str, default=".", help="root directory") | ||
return parser | ||
|
||
|
||
if __name__ == "__main__": | ||
opt = parse_args(argparse.ArgumentParser()).parse_args() | ||
stats(opt) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ mypkg = ["*.css", "*.js", "*.html"] | |
|
||
[project] | ||
name = "mccole" | ||
version = "0.2.4" | ||
version = "0.2.5" | ||
authors = [ | ||
{name = "Greg Wilson", email = "[email protected]"}, | ||
] | ||
|
@@ -31,6 +31,7 @@ dependencies = [ | |
"html5validator>=0.4.2", | ||
"jinja2>=3.1.4", | ||
"markdown>=3.6", | ||
"prettytable>=3.11", | ||
"ruff>=0.6.0", | ||
"tomli>=2.0.1", | ||
] | ||
|