Merge branch 'feature/idf_format_warnings' into 'master'

docs: add sphinx warnings in format_idf_target

See merge request espressif/esp-idf!10147
pull/5919/head
Krzysztof Budzynski 2020-09-14 15:17:11 +08:00
commit 55ff8e1ee0
1 zmienionych plików z 13 dodań i 0 usunięć

Wyświetl plik

@ -5,6 +5,7 @@ from docutils import io, nodes, statemachine, utils
from docutils.utils.error_reporting import SafeString, ErrorString
from docutils.parsers.rst import directives
from sphinx.directives.other import Include as BaseInclude
from sphinx.util import logging
def setup(app):
@ -21,6 +22,16 @@ def setup(app):
return {'parallel_read_safe': True, 'parallel_write_safe': True, 'version': '0.2'}
def check_content(content, docname):
# Log warnings for any {IDF_TARGET} expressions that haven't been replaced
logger = logging.getLogger(__name__)
errors = re.findall(r'{IDF_TARGET.*?}', content)
for err in errors:
logger.warning('Badly formated string substitution: {}'.format(err), location=docname)
class StringSubstituter:
""" Allows for string substitution of target related strings
before any markup is parsed
@ -113,6 +124,8 @@ class StringSubstituter:
def substitute_source_read_cb(self, app, docname, source):
source[0] = self.substitute(source[0])
check_content(source[0], docname)
class FormatedInclude(BaseInclude):