diff --git a/docs/conf_common.py b/docs/conf_common.py index cd1d3768e5..1820e0c352 100644 --- a/docs/conf_common.py +++ b/docs/conf_common.py @@ -26,6 +26,7 @@ from idf_extensions.util import download_file_if_missing # build_docs on the CI server sometimes fails under Python3. This is a workaround: sys.setrecursionlimit(3500) +config_dir = os.path.abspath(os.path.dirname(__file__)) # http://stackoverflow.com/questions/12772927/specifying-an-online-image-in-sphinx-restructuredtext-format # @@ -367,3 +368,31 @@ def setup(app): # note: we generate into xml_in and then copy_if_modified to xml dir app.config.breathe_projects = {"esp32-idf": os.path.join(app.config.build_dir, "xml_in/")} app.config.breathe_default_project = "esp32-idf" + + + setup_diag_font(app) + +def setup_diag_font(app): + # blockdiag and other tools require a font which supports their character set + # the font file is stored on the download server to save repo size + + font_name = { + 'en': 'DejaVuSans.ttf', + 'zh_CN': 'NotoSansSC-Regular.otf', + }[app.config.language] + + font_dir = os.path.join(config_dir, '_static') + assert os.path.exists(font_dir) + + print("Downloading font file %s for %s" % (font_name, app.config.language)) + download_file_if_missing('https://dl.espressif.com/dl/esp-idf/docs/_static/{}'.format(font_name), font_dir) + + font_path = os.path.abspath(os.path.join(font_dir, font_name)) + assert os.path.exists(font_path) + + app.config.blockdiag_fontpath = font_path + app.config.seqdiag_fontpath = font_path + app.config.actdiag_fontpath = font_path + app.config.nwdiag_fontpath = font_path + app.config.rackdiag_fontpath = font_path + app.config.packetdiag_fontpath = font_path diff --git a/docs/en/conf.py b/docs/en/conf.py index ec996f62f2..1bd7f8812f 100644 --- a/docs/en/conf.py +++ b/docs/en/conf.py @@ -10,7 +10,6 @@ import sys import os sys.path.insert(0, os.path.abspath('..')) from conf_common import * # noqa: F401, F403 - need to make available everything from common -from idf_extensions.util import download_file_if_missing # noqa: E402 - need to import from common folder # General information about the project. project = u'ESP-IDF Programming Guide' @@ -20,16 +19,4 @@ copyright = u'2016 - 2019, Espressif Systems (Shanghai) CO., LTD' # for a list of supported languages. language = 'en' -# Download font file that is stored on a separate server to save on esp-idf repository size. -print("Downloading font file") -download_file_if_missing('https://dl.espressif.com/dl/esp-idf/docs/_static/DejaVuSans.ttf', '../_static') - -# Set up font for blockdiag, nwdiag, rackdiag and packetdiag -blockdiag_fontpath = '../_static/DejaVuSans.ttf' -seqdiag_fontpath = '../_static/DejaVuSans.ttf' -actdiag_fontpath = '../_static/DejaVuSans.ttf' -nwdiag_fontpath = '../_static/DejaVuSans.ttf' -rackdiag_fontpath = '../_static/DejaVuSans.ttf' -packetdiag_fontpath = '../_static/DejaVuSans.ttf' - update_exclude_patterns(tags) # noqa: F405, need to import * from conf_common diff --git a/docs/zh_CN/conf.py b/docs/zh_CN/conf.py index b857bc0d75..70e377de10 100644 --- a/docs/zh_CN/conf.py +++ b/docs/zh_CN/conf.py @@ -20,16 +20,4 @@ copyright = u'2016 - 2019 乐鑫信息科技(上海)股份有限公司' # for a list of supported languages. language = 'zh_CN' -# Download font file that is stored on a separate server to save on esp-idf repository size. -print("Downloading font file") -download_file_if_missing('https://dl.espressif.com/dl/esp-idf/docs/_static/NotoSansSC-Regular.otf', '../_static') - -# Set up font for blockdiag, nwdiag, rackdiag and packetdiag -blockdiag_fontpath = '../_static/NotoSansSC-Regular.otf' -seqdiag_fontpath = '../_static/NotoSansSC-Regular.otf' -actdiag_fontpath = '../_static/NotoSansSC-Regular.otf' -nwdiag_fontpath = '../_static/NotoSansSC-Regular.otf' -rackdiag_fontpath = '../_static/NotoSansSC-Regular.otf' -packetdiag_fontpath = '../_static/NotoSansSC-Regular.otf' - update_exclude_patterns(tags) # noqa: F405, need to import * from conf_common