diff options
author | rebortg <github@ghlr.de> | 2021-06-23 20:20:26 +0200 |
---|---|---|
committer | rebortg <github@ghlr.de> | 2021-06-24 21:22:23 +0200 |
commit | 50294038fe6498fe398973b0294ac43d1658add5 (patch) | |
tree | 1d261cbc04b7491dee9c6c95b44f5716f8d3ba6a | |
parent | 49eb1d1fbffb2ee5fb0cf8866d2fee7f4af6fc1e (diff) | |
download | vyos-documentation-50294038fe6498fe398973b0294ac43d1658add5.tar.gz vyos-documentation-50294038fe6498fe398973b0294ac43d1658add5.zip |
vyos: add proofread meta data test
(cherry picked from commit 18e33cb14ab78c9899d9f9709e5810f3e11642b1)
-rw-r--r-- | docs/_ext/vyos.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/docs/_ext/vyos.py b/docs/_ext/vyos.py index 46ebae36..0a198821 100644 --- a/docs/_ext/vyos.py +++ b/docs/_ext/vyos.py @@ -1,6 +1,7 @@ import re import json import os +from datetime import datetime from docutils import io, nodes, utils, statemachine from docutils.parsers.rst.roles import set_classes from docutils.parsers.rst import Directive, directives, states @@ -9,6 +10,9 @@ from sphinx.util.docutils import SphinxDirective from testcoverage import get_working_commands +from sphinx.util import logging + +logger = logging.getLogger(__name__) def setup(app): @@ -74,6 +78,7 @@ def setup(app): app.add_directive('opcmd', OpCmdDirective) app.add_directive('cmdinclude', CfgInclude) app.connect('doctree-resolved', process_cmd_nodes) + app.connect('doctree-read', handle_document_meta_data) class CfgcmdList(nodes.General, nodes.Element): pass @@ -640,4 +645,23 @@ def vytask_role(name, rawtext, text, lineno, inliner, options={}, content=[]): def cmd_role(name, rawtext, text, lineno, inliner, options={}, content=[]): node = nodes.literal(text, text) - return [node], []
\ No newline at end of file + return [node], [] + + +def handle_document_meta_data(app, document): + docname = app.env.docname + lastproofread = app.env.metadata[docname].get('lastproofread', False) + if lastproofread: + try: + lastproofread_time = datetime.strptime(lastproofread, '%Y-%m-%d') + delta = datetime.now() - lastproofread_time + if delta.days > 180: + logger.warning(f'{delta.days} days since last proofread {app.env.doc2path(docname)}') + + except Exception as e: + logger.warning(f'lastproofread meta data error in {app.env.doc2path(docname)}: {e}') + else: + pass + #logger.warning(f'lastproofread meta data missing in {app.env.doc2path(docname)}') + + |