doc: Copy all doc/ contents and not just .rst files

To avoid having to refer to non-rst files artificially in order to get
them copied into the destination folder, make a raw full copy of the
doc/ folder instead of copying only the .rst files.

Fixes #9128

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit is contained in:
Carles Cufi 2018-08-06 11:51:53 +02:00 committed by Carles Cufí
parent 2cf47fed38
commit a0dbc7aa4b
2 changed files with 25 additions and 11 deletions

View file

@ -68,10 +68,10 @@ add_custom_target(
add_custom_target(
content
# Copy the .rst files in doc/ to the rst folder
# Copy all files in doc/ to the rst folder
COMMAND ${CMAKE_COMMAND} -E env
ZEPHYR_BUILD=${CMAKE_CURRENT_BINARY_DIR}
${PYTHON_EXECUTABLE} scripts/extract_content.py ${RST_OUT} doc
${PYTHON_EXECUTABLE} scripts/extract_content.py -a ${RST_OUT} doc
# Copy the .rst files in samples/ and boards/ to the rst folder
COMMAND ${CMAKE_COMMAND} -E env
ZEPHYR_BUILD=${CMAKE_CURRENT_BINARY_DIR}

View file

@ -8,6 +8,7 @@
# Very quick script to move docs from different places into the doc directory
# to fix the website and external links
import argparse
import errno
import filecmp
import fnmatch
@ -37,14 +38,15 @@ def copy_if_different(src, dst):
return
shutil.copyfile(src, dst)
def get_rst_files(dest, dir):
def get_files(all, dest, dir):
matches = []
for root, dirnames, filenames in os.walk('%s/%s' %(ZEPHYR_BASE, dir)):
if ZEPHYR_BUILD:
if os.path.normpath(root).startswith(os.path.normpath(ZEPHYR_BUILD)):
# Build folder, skip it
continue
for filename in fnmatch.filter(filenames, '*.rst'):
for filename in fnmatch.filter(filenames, '*' if all else '*.rst'):
matches.append(os.path.join(root, filename))
for file in matches:
frel = file.replace(ZEPHYR_BASE,"").strip("/")
@ -54,6 +56,11 @@ def get_rst_files(dest, dir):
copy_if_different(file, os.path.join(dest, frel))
# Inspect only .rst files for directives referencing other files
# we'll need to copy (as configured in the DIRECTIVES variable)
if not fnmatch.fnmatch(file, "*.rst"):
continue
try:
with open(file, encoding="utf-8") as f:
content = f.readlines()
@ -92,15 +99,22 @@ def get_rst_files(dest, dir):
def main():
if len(sys.argv) < 3:
print("usage: {} <dest> <org dirs>", file=sys.stderr)
sys.exit(1)
parser = argparse.ArgumentParser(description='Recursively copy .rst files '
'from the origin folder(s) to the '
'destination folder, plus files referenced '
'in those .rst files by a configurable '
'list of directives: {}.'.format(DIRECTIVES))
dest = sys.argv[1]
content_dirs = sys.argv[2:]
parser.add_argument('-a', '--all', action='store_true', help='Copy all files '
'(recursively) in the specified source folder(s).')
parser.add_argument('dest', nargs=1)
parser.add_argument('src', nargs='+')
args = parser.parse_args()
for d in content_dirs:
get_rst_files(dest, d)
dest = args.dest[0]
for d in args.src:
get_files(args.all, dest, d)
if __name__ == "__main__":
main()