mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 04:04:31 +02:00
docs: add sphinx warnings in format_idf_target
format_idf_target will now log sphinx warnings for any {IDF_TARGET_X} that were not replaced.
This commit is contained in:
@@ -5,6 +5,7 @@ from docutils import io, nodes, statemachine, utils
|
|||||||
from docutils.utils.error_reporting import SafeString, ErrorString
|
from docutils.utils.error_reporting import SafeString, ErrorString
|
||||||
from docutils.parsers.rst import directives
|
from docutils.parsers.rst import directives
|
||||||
from sphinx.directives.other import Include as BaseInclude
|
from sphinx.directives.other import Include as BaseInclude
|
||||||
|
from sphinx.util import logging
|
||||||
|
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
@@ -21,6 +22,16 @@ def setup(app):
|
|||||||
return {'parallel_read_safe': True, 'parallel_write_safe': True, 'version': '0.2'}
|
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:
|
class StringSubstituter:
|
||||||
""" Allows for string substitution of target related strings
|
""" Allows for string substitution of target related strings
|
||||||
before any markup is parsed
|
before any markup is parsed
|
||||||
@@ -113,6 +124,8 @@ class StringSubstituter:
|
|||||||
def substitute_source_read_cb(self, app, docname, source):
|
def substitute_source_read_cb(self, app, docname, source):
|
||||||
source[0] = self.substitute(source[0])
|
source[0] = self.substitute(source[0])
|
||||||
|
|
||||||
|
check_content(source[0], docname)
|
||||||
|
|
||||||
|
|
||||||
class FormatedInclude(BaseInclude):
|
class FormatedInclude(BaseInclude):
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user