revert r44887, changes were OK but caused too many problems, better do this as a smaller patch.
sphinx_doc_gen.sh broke building docs - - examples/ svn directory was being removed since it assumed an out-of-source build. - include references somehow stopped working (didnt find why). also fixed an unrelated error with building docs in object_utils.py
This commit is contained in:
@@ -35,7 +35,7 @@ API dump in RST files
|
|||||||
./blender.bin -b -P doc/python_api/sphinx_doc_gen.py -- -o ../python_api
|
./blender.bin -b -P doc/python_api/sphinx_doc_gen.py -- -o ../python_api
|
||||||
|
|
||||||
For quick builds:
|
For quick builds:
|
||||||
./blender.bin -b -P doc/python_api/sphinx_doc_gen.py -- -p
|
./blender.bin -b -P doc/python_api/sphinx_doc_gen.py -- -q
|
||||||
|
|
||||||
|
|
||||||
Sphinx: HTML generation
|
Sphinx: HTML generation
|
||||||
@@ -75,7 +75,6 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import inspect
|
import inspect
|
||||||
import shutil
|
import shutil
|
||||||
import logging
|
|
||||||
|
|
||||||
from platform import platform
|
from platform import platform
|
||||||
PLATFORM = platform().split('-')[0].lower() # 'linux', 'darwin', 'windows'
|
PLATFORM = platform().split('-')[0].lower() # 'linux', 'darwin', 'windows'
|
||||||
@@ -96,44 +95,26 @@ def handle_args():
|
|||||||
)
|
)
|
||||||
|
|
||||||
# optional arguments
|
# optional arguments
|
||||||
parser.add_argument("-p", "--partial",
|
|
||||||
dest="partial",
|
|
||||||
type=str,
|
|
||||||
default="",
|
|
||||||
help="Use a wildcard to only build specific module(s)\n"
|
|
||||||
"Example: --partial bmesh*\n",
|
|
||||||
required=False)
|
|
||||||
|
|
||||||
parser.add_argument("-f", "--fullrebuild",
|
|
||||||
dest="full_rebuild",
|
|
||||||
default=False,
|
|
||||||
action='store_true',
|
|
||||||
help="Rewrite all rst files in sphinx-in/ "
|
|
||||||
"(default=False)",
|
|
||||||
required=False)
|
|
||||||
|
|
||||||
parser.add_argument("-b", "--bpy",
|
|
||||||
dest="bpy",
|
|
||||||
default=False,
|
|
||||||
action='store_true',
|
|
||||||
help="Write the rst file of the bpy module "
|
|
||||||
"(default=False)",
|
|
||||||
required=False)
|
|
||||||
|
|
||||||
parser.add_argument("-o", "--output",
|
parser.add_argument("-o", "--output",
|
||||||
dest="output_dir",
|
dest="output_dir",
|
||||||
type=str,
|
type=str,
|
||||||
default=SCRIPT_DIR,
|
default=SCRIPT_DIR,
|
||||||
help="Path of the API docs (default=<script dir>)",
|
# XXX, THIS ISNT WORKING, EXAMPLE SCRIPTS WILL NOT BE FOUND
|
||||||
|
help="Path of the API docs (default=<script dir>).",
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
parser.add_argument("-l", "--bpy-log",
|
parser.add_argument("-B", "--sphinx-build",
|
||||||
dest="bpy_log",
|
dest="sphinx_build",
|
||||||
default=False,
|
default=False,
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help=
|
help="Run sphinx-build SPHINX_IN SPHINX_OUT (default=False)",
|
||||||
"Log the output of the api dump (default=False).\n"
|
required=False)
|
||||||
"If given, save logs in OUTPUT_DIR/.bpy.log",
|
|
||||||
|
parser.add_argument("-N", "--sphinx-named-output",
|
||||||
|
dest="sphinx_named_output",
|
||||||
|
default=False,
|
||||||
|
action='store_true',
|
||||||
|
help="Add the theme name to the html dir name (default=False)",
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
parser.add_argument("-T", "--sphinx-theme",
|
parser.add_argument("-T", "--sphinx-theme",
|
||||||
@@ -154,51 +135,25 @@ def handle_args():
|
|||||||
# 'sphinxdoc', 'traditional'], # sphinx
|
# 'sphinxdoc', 'traditional'], # sphinx
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
parser.add_argument("-N", "--sphinx-named-output",
|
parser.add_argument("-f", "--fullrebuild",
|
||||||
dest="sphinx_named_output",
|
dest="full_rebuild",
|
||||||
default=False,
|
default=False,
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help="Add the theme name to the html dir name.\n"
|
help="Rewrite all rst files in sphinx-in/ (default=False)",
|
||||||
"Example: \"sphinx-out_haiku\" (default=False)",
|
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
parser.add_argument("-B", "--sphinx-build",
|
parser.add_argument("-p", "--partial",
|
||||||
dest="sphinx_build",
|
dest="partial",
|
||||||
default=False,
|
type=str,
|
||||||
action='store_true',
|
default="",
|
||||||
help="Build the html docs by running:\n"
|
help="Use a wildcard to only build spesific module(s)",
|
||||||
"sphinx-build SPHINX_IN SPHINX_OUT\n"
|
|
||||||
"(default=False; does not depend on -P)",
|
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
parser.add_argument("-P", "--sphinx-build-pdf",
|
parser.add_argument("-b", "--bpy",
|
||||||
dest="sphinx_build_pdf",
|
dest="bpy",
|
||||||
default=False,
|
default=False,
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help="Build the pdf by running:\n"
|
help="Write the rst file of the bpy module (default=False)",
|
||||||
"sphinx-build -b latex SPHINX_IN SPHINX_OUT_PDF\n"
|
|
||||||
"(default=False; does not depend on -B)",
|
|
||||||
required=False)
|
|
||||||
|
|
||||||
parser.add_argument("-R", "--pack-reference",
|
|
||||||
dest="pack_reference",
|
|
||||||
default=False,
|
|
||||||
action='store_true',
|
|
||||||
help="Pack all necessary files in the deployed dir.\n"
|
|
||||||
"(default=False; use with -B and -P)",
|
|
||||||
required=False)
|
|
||||||
|
|
||||||
parser.add_argument("-L", "--sphinx-log",
|
|
||||||
dest="sphinx_log",
|
|
||||||
default=False,
|
|
||||||
action='store_true',
|
|
||||||
help=
|
|
||||||
"Log warnings and errors (default=False).\n"
|
|
||||||
"If given, eventually save logs in:\n"
|
|
||||||
"* OUTPUT_DIR/.sphinx-build.log\n"
|
|
||||||
"* OUTPUT_DIR/.sphinx-build_pdf.log\n"
|
|
||||||
"* OUTPUT_DIR/.latex_make.log",
|
|
||||||
# see SPHINX_BUILD_LOG
|
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
# parse only the args passed after '--'
|
# parse only the args passed after '--'
|
||||||
@@ -213,29 +168,11 @@ ARGS = handle_args()
|
|||||||
|
|
||||||
# ----------------------------------BPY-----------------------------------------
|
# ----------------------------------BPY-----------------------------------------
|
||||||
|
|
||||||
BPY_LOGGER = logging.getLogger('bpy')
|
|
||||||
BPY_LOGGER.setLevel(logging.DEBUG)
|
|
||||||
|
|
||||||
if ARGS.bpy_log:
|
|
||||||
BPY_LOGFILE = os.path.join(ARGS.output_dir,".bpy.log")
|
|
||||||
bpy_logfilehandler = logging.FileHandler(BPY_LOGFILE, mode="w")
|
|
||||||
bpy_logfilehandler.setLevel(logging.DEBUG)
|
|
||||||
BPY_LOGGER.addHandler(bpy_logfilehandler)
|
|
||||||
|
|
||||||
# using a FileHandler seems to disable the stdout, so we add a StreamHandler
|
|
||||||
bpy_log_stdout_handler = logging.StreamHandler(stream=sys.stdout)
|
|
||||||
bpy_log_stdout_handler.setLevel(logging.DEBUG)
|
|
||||||
BPY_LOGGER.addHandler(bpy_log_stdout_handler)
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# for quick rebuilds
|
# for quick rebuilds
|
||||||
rm -rf /b/doc/python_api/sphinx-* && \
|
rm -rf /b/doc/python_api/sphinx-* && \
|
||||||
./blender.bin -b -noaudio --factory-startup -P doc/python_api/sphinx_doc_gen.py && \
|
./blender.bin --background -noaudio --factory-startup --python doc/python_api/sphinx_doc_gen.py && \
|
||||||
sphinx-build doc/python_api/sphinx-in doc/python_api/sphinx-out
|
sphinx-build doc/python_api/sphinx-in doc/python_api/sphinx-out
|
||||||
|
|
||||||
or
|
|
||||||
|
|
||||||
./blender.bin -b -noaudio --factory-startup -P doc/python_api/sphinx_doc_gen.py -- -f -B
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Switch for quick testing so doc-builds don't take so long
|
# Switch for quick testing so doc-builds don't take so long
|
||||||
@@ -291,7 +228,7 @@ else:
|
|||||||
del m
|
del m
|
||||||
del fnmatch
|
del fnmatch
|
||||||
|
|
||||||
BPY_LOGGER.debug("Partial Doc Build, Skipping: %s\n" % "\n ".join(sorted(EXCLUDE_MODULES)))
|
print("Partial Doc Build, Skipping: %s\n" % "\n ".join(sorted(EXCLUDE_MODULES)))
|
||||||
|
|
||||||
#
|
#
|
||||||
# done filtering
|
# done filtering
|
||||||
@@ -300,7 +237,7 @@ else:
|
|||||||
try:
|
try:
|
||||||
__import__("aud")
|
__import__("aud")
|
||||||
except ImportError:
|
except ImportError:
|
||||||
BPY_LOGGER.debug("Warning: Built without 'aud' module, docs incomplete...")
|
print("Warning: Built without 'aud' module, docs incomplete...")
|
||||||
EXCLUDE_MODULES = EXCLUDE_MODULES + ("aud", )
|
EXCLUDE_MODULES = EXCLUDE_MODULES + ("aud", )
|
||||||
|
|
||||||
# examples
|
# examples
|
||||||
@@ -311,7 +248,7 @@ for f in os.listdir(EXAMPLES_DIR):
|
|||||||
EXAMPLE_SET.add(os.path.splitext(f)[0])
|
EXAMPLE_SET.add(os.path.splitext(f)[0])
|
||||||
EXAMPLE_SET_USED = set()
|
EXAMPLE_SET_USED = set()
|
||||||
|
|
||||||
# rst files dir
|
#rst files dir
|
||||||
RST_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, "rst"))
|
RST_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, "rst"))
|
||||||
|
|
||||||
# extra info, not api reference docs
|
# extra info, not api reference docs
|
||||||
@@ -327,36 +264,10 @@ INFO_DOCS = (
|
|||||||
# only support for properties atm.
|
# only support for properties atm.
|
||||||
RNA_BLACKLIST = {
|
RNA_BLACKLIST = {
|
||||||
# XXX messes up PDF!, really a bug but for now just workaround.
|
# XXX messes up PDF!, really a bug but for now just workaround.
|
||||||
"UserPreferencesSystem": {"language" }
|
"UserPreferencesSystem": {"language", }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# --------------------configure compile time options----------------------------
|
|
||||||
|
|
||||||
# -------------------------------BLENDER----------------------------------------
|
|
||||||
|
|
||||||
blender_version_strings = [str(v) for v in bpy.app.version]
|
|
||||||
|
|
||||||
# converting bytes to strings, due to #30154
|
|
||||||
BLENDER_REVISION = str(bpy.app.build_revision, 'utf_8')
|
|
||||||
BLENDER_DATE = str(bpy.app.build_date, 'utf_8')
|
|
||||||
|
|
||||||
BLENDER_VERSION_DOTS = ".".join(blender_version_strings) # '2.62.1'
|
|
||||||
if BLENDER_REVISION != "Unknown":
|
|
||||||
BLENDER_VERSION_DOTS += " r" + BLENDER_REVISION # '2.62.1 r44584'
|
|
||||||
|
|
||||||
BLENDER_VERSION_PATH = "_".join(blender_version_strings) # '2_62_1'
|
|
||||||
if bpy.app.version_cycle == "release":
|
|
||||||
BLENDER_VERSION_PATH = "%s%s_release" % ("_".join(blender_version_strings[:2]),
|
|
||||||
bpy.app.version_char) # '2_62_release'
|
|
||||||
|
|
||||||
# --------------------------DOWNLOADABLE FILES----------------------------------
|
|
||||||
|
|
||||||
REFERENCE_NAME = "blender_python_reference_%s" % BLENDER_VERSION_PATH
|
|
||||||
REFERENCE_PATH = os.path.join(ARGS.output_dir, REFERENCE_NAME)
|
|
||||||
BLENDER_PDF_FILENAME = "%s.pdf" % REFERENCE_NAME
|
|
||||||
BLENDER_ZIP_FILENAME = "%s.zip" % REFERENCE_NAME
|
|
||||||
|
|
||||||
# -------------------------------SPHINX-----------------------------------------
|
# -------------------------------SPHINX-----------------------------------------
|
||||||
|
|
||||||
SPHINX_THEMES = {'bf': ['blender-org'], # , 'naiad',
|
SPHINX_THEMES = {'bf': ['blender-org'], # , 'naiad',
|
||||||
@@ -375,43 +286,37 @@ if ARGS.sphinx_theme not in available_themes:
|
|||||||
print ("Please choose a theme among: %s" % ', '.join(available_themes))
|
print ("Please choose a theme among: %s" % ', '.join(available_themes))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if ARGS.sphinx_theme in SPHINX_THEMES['bf']:
|
|
||||||
SPHINX_THEME_DIR = os.path.join(ARGS.output_dir, ARGS.sphinx_theme)
|
|
||||||
SPHINX_THEME_SVN_DIR = os.path.join(SCRIPT_DIR, ARGS.sphinx_theme)
|
|
||||||
|
|
||||||
SPHINX_IN = os.path.join(ARGS.output_dir, "sphinx-in")
|
SPHINX_IN = os.path.join(ARGS.output_dir, "sphinx-in")
|
||||||
SPHINX_IN_TMP = SPHINX_IN + "-tmp"
|
SPHINX_IN_TMP = SPHINX_IN + "-tmp"
|
||||||
SPHINX_OUT = os.path.join(ARGS.output_dir, "sphinx-out")
|
SPHINX_OUT = os.path.join(ARGS.output_dir, "sphinx-out")
|
||||||
if ARGS.sphinx_named_output:
|
if ARGS.sphinx_named_output:
|
||||||
SPHINX_OUT += "_%s" % ARGS.sphinx_theme
|
SPHINX_OUT += "_%s" % ARGS.sphinx_theme
|
||||||
|
|
||||||
# html build
|
if ARGS.sphinx_theme in SPHINX_THEMES['bf']:
|
||||||
if ARGS.sphinx_build:
|
SPHINX_THEME_DIR = os.path.join(ARGS.output_dir, ARGS.sphinx_theme)
|
||||||
SPHINX_BUILD = ["sphinx-build", SPHINX_IN, SPHINX_OUT]
|
SPHINX_THEME_SVN_DIR = os.path.join(SCRIPT_DIR, ARGS.sphinx_theme)
|
||||||
|
|
||||||
if ARGS.sphinx_log:
|
# ------------------------------------------------------------------------------
|
||||||
SPHINX_BUILD_LOG = os.path.join(ARGS.output_dir, ".sphinx-build.log")
|
|
||||||
SPHINX_BUILD = ["sphinx-build",
|
|
||||||
"-w", SPHINX_BUILD_LOG,
|
|
||||||
SPHINX_IN, SPHINX_OUT]
|
|
||||||
|
|
||||||
# pdf build
|
# configure compile time options
|
||||||
if ARGS.sphinx_build_pdf:
|
|
||||||
SPHINX_OUT_PDF = os.path.join(ARGS.output_dir, "sphinx-out_pdf")
|
|
||||||
SPHINX_BUILD_PDF = ["sphinx-build",
|
|
||||||
"-b", "latex",
|
|
||||||
SPHINX_IN, SPHINX_OUT_PDF]
|
|
||||||
SPHINX_MAKE_PDF = ["make", "-C", SPHINX_OUT_PDF]
|
|
||||||
SPHINX_MAKE_PDF_STDOUT = None
|
|
||||||
|
|
||||||
if ARGS.sphinx_log:
|
# -------------------------------BLENDER----------------------------------------
|
||||||
SPHINX_BUILD_PDF_LOG = os.path.join(ARGS.output_dir, ".sphinx-build_pdf.log")
|
|
||||||
SPHINX_BUILD_PDF = ["sphinx-build", "-b", "latex",
|
'''
|
||||||
"-w", SPHINX_BUILD_PDF_LOG,
|
blender version
|
||||||
SPHINX_IN, SPHINX_OUT_PDF]
|
'''
|
||||||
|
version_strings = [str(v) for v in bpy.app.version]
|
||||||
|
|
||||||
|
BLENDER_VERSION_DOTS = ".".join(version_strings) # '2.62.1'
|
||||||
|
if bpy.app.build_revision != b"Unknown":
|
||||||
|
# converting bytes to strings, due to #30154
|
||||||
|
BLENDER_VERSION_DOTS += " r" + str(bpy.app.build_revision, 'utf_8') # '2.62.1 r44584'
|
||||||
|
|
||||||
|
BLENDER_VERSION_PDF = "_".join(version_strings) # '2_62_1'
|
||||||
|
if bpy.app.version_cycle == "release":
|
||||||
|
BLENDER_VERSION_PDF = "%s%s_release" % ("_".join(version_strings[:2]),
|
||||||
|
bpy.app.version_char) # '2_62_release'
|
||||||
|
|
||||||
sphinx_make_pdf_log = os.path.join(ARGS.output_dir, ".latex_make.log")
|
|
||||||
SPHINX_MAKE_PDF_STDOUT = open(sphinx_make_pdf_log, "w", encoding="utf-8")
|
|
||||||
|
|
||||||
# --------------------------------API DUMP--------------------------------------
|
# --------------------------------API DUMP--------------------------------------
|
||||||
|
|
||||||
@@ -511,7 +416,7 @@ def write_example_ref(ident, fw, example_id, ext="py"):
|
|||||||
EXAMPLE_SET_USED.add(example_id)
|
EXAMPLE_SET_USED.add(example_id)
|
||||||
else:
|
else:
|
||||||
if bpy.app.debug:
|
if bpy.app.debug:
|
||||||
BPY_LOGGER.debug("\tskipping example: " + example_id)
|
print("\tskipping example:", example_id)
|
||||||
|
|
||||||
# Support for numbered files bpy.types.Operator -> bpy.types.Operator.1.py
|
# Support for numbered files bpy.types.Operator -> bpy.types.Operator.1.py
|
||||||
i = 1
|
i = 1
|
||||||
@@ -798,7 +703,7 @@ def pymodule2sphinx(basepath, module_name, module, title):
|
|||||||
write_indented_lines(" ", fw, "constant value %s" % repr(value), False)
|
write_indented_lines(" ", fw, "constant value %s" % repr(value), False)
|
||||||
fw("\n")
|
fw("\n")
|
||||||
else:
|
else:
|
||||||
BPY_LOGGER.debug("\tnot documenting %s.%s of %r type" % (module_name, attribute, value_type.__name__))
|
print("\tnot documenting %s.%s of %r type" % (module_name, attribute, value_type.__name__))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
attribute_set.add(attribute)
|
attribute_set.add(attribute)
|
||||||
@@ -806,7 +711,7 @@ def pymodule2sphinx(basepath, module_name, module, title):
|
|||||||
del module_dir_value_type
|
del module_dir_value_type
|
||||||
|
|
||||||
# TODO, bpy_extras does this already, mathutils not.
|
# TODO, bpy_extras does this already, mathutils not.
|
||||||
'''
|
"""
|
||||||
if submodules:
|
if submodules:
|
||||||
fw("\n"
|
fw("\n"
|
||||||
"**********\n"
|
"**********\n"
|
||||||
@@ -817,7 +722,7 @@ def pymodule2sphinx(basepath, module_name, module, title):
|
|||||||
for attribute, submod in submodules:
|
for attribute, submod in submodules:
|
||||||
fw("* :mod:`%s.%s`\n" % (module_name, attribute))
|
fw("* :mod:`%s.%s`\n" % (module_name, attribute))
|
||||||
fw("\n")
|
fw("\n")
|
||||||
'''
|
"""
|
||||||
|
|
||||||
# write collected classes now
|
# write collected classes now
|
||||||
for (type_name, value) in classes:
|
for (type_name, value) in classes:
|
||||||
@@ -966,9 +871,8 @@ def pycontext2sphinx(basepath):
|
|||||||
|
|
||||||
|
|
||||||
def pyrna_enum2sphinx(prop, use_empty_descriptions=False):
|
def pyrna_enum2sphinx(prop, use_empty_descriptions=False):
|
||||||
'''
|
""" write a bullet point list of enum + descrptons
|
||||||
write a bullet point list of enum + descriptions
|
"""
|
||||||
'''
|
|
||||||
|
|
||||||
if use_empty_descriptions:
|
if use_empty_descriptions:
|
||||||
ok = True
|
ok = True
|
||||||
@@ -991,9 +895,8 @@ def pyrna_enum2sphinx(prop, use_empty_descriptions=False):
|
|||||||
|
|
||||||
|
|
||||||
def pyrna2sphinx(basepath):
|
def pyrna2sphinx(basepath):
|
||||||
'''
|
""" bpy.types and bpy.ops
|
||||||
bpy.types and bpy.ops
|
"""
|
||||||
'''
|
|
||||||
structs, funcs, ops, props = rna_info.BuildRNAInfo()
|
structs, funcs, ops, props = rna_info.BuildRNAInfo()
|
||||||
if FILTER_BPY_TYPES is not None:
|
if FILTER_BPY_TYPES is not None:
|
||||||
structs = {k: v for k, v in structs.items() if k[1] in FILTER_BPY_TYPES}
|
structs = {k: v for k, v in structs.items() if k[1] in FILTER_BPY_TYPES}
|
||||||
@@ -1410,11 +1313,11 @@ def write_rst_contents(basepath):
|
|||||||
fw(" Blender Documentation contents\n")
|
fw(" Blender Documentation contents\n")
|
||||||
fw("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n")
|
fw("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n")
|
||||||
fw("\n")
|
fw("\n")
|
||||||
fw("Welcome, this document is an API reference for Blender %s, built %s.\n" % (BLENDER_VERSION_DOTS, BLENDER_DATE))
|
fw("Welcome, this document is an API reference for Blender %s. built %s.\n" % (BLENDER_VERSION_DOTS, str(bpy.app.build_date, 'utf_8')))
|
||||||
fw("\n")
|
fw("\n")
|
||||||
|
|
||||||
# fw("`A PDF version of this document is also available <%s>`_\n" % BLENDER_PDF_FILENAME)
|
# fw("`A PDF version of this document is also available <blender_python_reference_%s.pdf>`_\n" % BLENDER_VERSION_PDF)
|
||||||
fw("`A compressed ZIP file of this site is available <%s>`_\n" % BLENDER_ZIP_FILENAME)
|
fw("`A compressed ZIP file of this site is available <blender_python_reference_%s.zip>`_\n" % BLENDER_VERSION_PDF)
|
||||||
|
|
||||||
fw("\n")
|
fw("\n")
|
||||||
|
|
||||||
@@ -1701,7 +1604,7 @@ def align_sphinx_in_to_sphinx_in_tmp():
|
|||||||
# remove deprecated files that have been removed
|
# remove deprecated files that have been removed
|
||||||
for f in sorted(sphinx_in_files):
|
for f in sorted(sphinx_in_files):
|
||||||
if f not in sphinx_in_tmp_files:
|
if f not in sphinx_in_tmp_files:
|
||||||
BPY_LOGGER.debug("\tdeprecated: %s" % f)
|
print("\tdeprecated: %s" % f)
|
||||||
os.remove(os.path.join(SPHINX_IN, f))
|
os.remove(os.path.join(SPHINX_IN, f))
|
||||||
|
|
||||||
# freshen with new files.
|
# freshen with new files.
|
||||||
@@ -1715,26 +1618,10 @@ def align_sphinx_in_to_sphinx_in_tmp():
|
|||||||
do_copy = False
|
do_copy = False
|
||||||
|
|
||||||
if do_copy:
|
if do_copy:
|
||||||
BPY_LOGGER.debug("\tupdating: %s" % f)
|
print("\tupdating: %s" % f)
|
||||||
shutil.copy(f_from, f_to)
|
shutil.copy(f_from, f_to)
|
||||||
|
|
||||||
|
|
||||||
def refactor_sphinx_log(sphinx_logfile):
|
|
||||||
refactored_log = []
|
|
||||||
with open(sphinx_logfile, "r", encoding="utf-8") as original_logfile:
|
|
||||||
lines = set(original_logfile.readlines())
|
|
||||||
for line in lines:
|
|
||||||
if 'warning' in line.lower() or 'error' in line.lower():
|
|
||||||
line = line.strip().split(None, 2)
|
|
||||||
if len(line) == 3:
|
|
||||||
location, kind, msg = line
|
|
||||||
location = os.path.relpath(location, start=SPHINX_IN)
|
|
||||||
refactored_log.append((kind, location, msg))
|
|
||||||
with open(sphinx_logfile, "w", encoding="utf-8") as refactored_logfile:
|
|
||||||
for log in sorted(refactored_log):
|
|
||||||
refactored_logfile.write("%-12s %s\n %s\n" % log)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
# dirs preparation
|
# dirs preparation
|
||||||
@@ -1743,36 +1630,27 @@ def main():
|
|||||||
os.mkdir(dir_path)
|
os.mkdir(dir_path)
|
||||||
|
|
||||||
# dump the api in rst files
|
# dump the api in rst files
|
||||||
shutil.rmtree(SPHINX_IN_TMP, True)
|
|
||||||
rna2sphinx(SPHINX_IN_TMP)
|
|
||||||
if ARGS.full_rebuild:
|
if ARGS.full_rebuild:
|
||||||
# only for full updates
|
# only for full updates
|
||||||
shutil.rmtree(SPHINX_IN, True)
|
shutil.rmtree(SPHINX_IN, True)
|
||||||
|
shutil.rmtree(SPHINX_OUT, True)
|
||||||
|
rna2sphinx(SPHINX_IN_TMP)
|
||||||
shutil.copytree(SPHINX_IN_TMP,
|
shutil.copytree(SPHINX_IN_TMP,
|
||||||
SPHINX_IN,
|
SPHINX_IN,
|
||||||
copy_function=shutil.copy)
|
copy_function=shutil.copy)
|
||||||
if ARGS.sphinx_build:
|
|
||||||
shutil.rmtree(SPHINX_OUT, True)
|
|
||||||
if ARGS.sphinx_build_pdf:
|
|
||||||
shutil.rmtree(SPHINX_OUT_PDF, True)
|
|
||||||
else:
|
else:
|
||||||
# move changed files in SPHINX_IN
|
# write here, then move
|
||||||
|
shutil.rmtree(SPHINX_IN_TMP, True)
|
||||||
|
rna2sphinx(SPHINX_IN_TMP)
|
||||||
align_sphinx_in_to_sphinx_in_tmp()
|
align_sphinx_in_to_sphinx_in_tmp()
|
||||||
|
|
||||||
# report which example files weren't used
|
# report which example files weren't used
|
||||||
EXAMPLE_SET_UNUSED = EXAMPLE_SET - EXAMPLE_SET_USED
|
EXAMPLE_SET_UNUSED = EXAMPLE_SET - EXAMPLE_SET_USED
|
||||||
if EXAMPLE_SET_UNUSED:
|
if EXAMPLE_SET_UNUSED:
|
||||||
BPY_LOGGER.debug("\nUnused examples found in '%s'..." % EXAMPLES_DIR)
|
print("\nUnused examples found in '%s'..." % EXAMPLES_DIR)
|
||||||
for f in EXAMPLE_SET_UNUSED:
|
for f in EXAMPLE_SET_UNUSED:
|
||||||
BPY_LOGGER.debug(" %s.py" % f)
|
print(" %s.py" % f)
|
||||||
BPY_LOGGER.debug(" %d total\n" % len(EXAMPLE_SET_UNUSED))
|
print(" %d total\n" % len(EXAMPLE_SET_UNUSED))
|
||||||
|
|
||||||
# copy the examples dir
|
|
||||||
examples_dir = os.path.join(ARGS.output_dir, "examples")
|
|
||||||
shutil.rmtree(examples_dir, True)
|
|
||||||
shutil.copytree(EXAMPLES_DIR,
|
|
||||||
examples_dir,
|
|
||||||
ignore=shutil.ignore_patterns(*(".svn",)))
|
|
||||||
|
|
||||||
# eventually, copy the theme in the output directory
|
# eventually, copy the theme in the output directory
|
||||||
if ARGS.sphinx_theme in SPHINX_THEMES['bf']:
|
if ARGS.sphinx_theme in SPHINX_THEMES['bf']:
|
||||||
@@ -1781,68 +1659,12 @@ def main():
|
|||||||
SPHINX_THEME_DIR,
|
SPHINX_THEME_DIR,
|
||||||
copy_function=shutil.copy)
|
copy_function=shutil.copy)
|
||||||
|
|
||||||
# eventually, build the html docs
|
# eventually, build the docs
|
||||||
if ARGS.sphinx_build:
|
if ARGS.sphinx_build:
|
||||||
import subprocess
|
import subprocess
|
||||||
subprocess.call(SPHINX_BUILD)
|
sphinx_build_command = "sphinx-build %s %s" % (SPHINX_IN, SPHINX_OUT)
|
||||||
|
print ('\n%s\n' % sphinx_build_command)
|
||||||
# sphinx-build log cleanup+sort
|
subprocess.call(sphinx_build_command, shell=True)
|
||||||
if ARGS.sphinx_log:
|
|
||||||
if os.stat(SPHINX_BUILD_LOG).st_size:
|
|
||||||
refactor_sphinx_log(SPHINX_BUILD_LOG)
|
|
||||||
|
|
||||||
# eventually, build the pdf docs
|
|
||||||
if ARGS.sphinx_build_pdf:
|
|
||||||
import subprocess
|
|
||||||
subprocess.call(SPHINX_BUILD_PDF)
|
|
||||||
subprocess.call(SPHINX_MAKE_PDF, stdout=SPHINX_MAKE_PDF_STDOUT)
|
|
||||||
# sphinx-build log cleanup+sort
|
|
||||||
if ARGS.sphinx_log:
|
|
||||||
if os.stat(SPHINX_BUILD_PDF_LOG).st_size:
|
|
||||||
refactor_sphinx_log(SPHINX_BUILD_PDF_LOG)
|
|
||||||
|
|
||||||
# eventually, prepare the dir to be deployed online (REFERENCE_PATH)
|
|
||||||
if ARGS.pack_reference:
|
|
||||||
|
|
||||||
if ARGS.sphinx_build:
|
|
||||||
# delete REFERENCE_PATH
|
|
||||||
if os.path.exists(REFERENCE_PATH):
|
|
||||||
shutil.rmtree(REFERENCE_PATH, True)
|
|
||||||
|
|
||||||
# copy SPHINX_OUT to the REFERENCE_PATH
|
|
||||||
ignores = ('.doctrees', 'objects.inv', '.buildinfo')
|
|
||||||
shutil.copytree(SPHINX_OUT,
|
|
||||||
REFERENCE_PATH,
|
|
||||||
ignore=shutil.ignore_patterns(*ignores))
|
|
||||||
|
|
||||||
# zip REFERENCE_PATH
|
|
||||||
from zipfile import ZipFile
|
|
||||||
# zip out of REFERENCE_PATH to avoid infinite loop
|
|
||||||
zip_tmp_path = os.path.join(ARGS.output_dir, BLENDER_ZIP_FILENAME)
|
|
||||||
zip_final_path = os.path.join(REFERENCE_PATH, BLENDER_ZIP_FILENAME)
|
|
||||||
with ZipFile(zip_tmp_path, 'w') as tmpzip:
|
|
||||||
for base, dirs, files in os.walk(REFERENCE_PATH):
|
|
||||||
zipbase = os.path.relpath(base, ARGS.output_dir)
|
|
||||||
for filename in files:
|
|
||||||
tmpzip.write(os.path.join(base, filename),
|
|
||||||
arcname = os.path.join(zipbase, filename))
|
|
||||||
|
|
||||||
# move the zip to REFERENCE_PATH
|
|
||||||
os.rename(zip_tmp_path, zip_final_path)
|
|
||||||
|
|
||||||
if ARGS.sphinx_build_pdf:
|
|
||||||
# copy the pdf to REFERENCE_PATH
|
|
||||||
shutil.copy(os.path.join(SPHINX_OUT_PDF, "contents.pdf"),
|
|
||||||
os.path.join(REFERENCE_PATH, BLENDER_PDF_FILENAME))
|
|
||||||
'''
|
|
||||||
TODO
|
|
||||||
1) uncomment the link to the pdf in write_rst_contents()
|
|
||||||
2) do we want to zip also zip the pdf too?
|
|
||||||
if so move the zipping after the pdf generation
|
|
||||||
|
|
||||||
3) Unused examples found in '/home/user/my/blender/builds/blender/doc/python_api/examples'...
|
|
||||||
check against patterns in -p
|
|
||||||
'''
|
|
||||||
|
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
@@ -21,14 +21,14 @@
|
|||||||
__all__ = (
|
__all__ = (
|
||||||
"add_object_align_init",
|
"add_object_align_init",
|
||||||
"object_data_add",
|
"object_data_add",
|
||||||
"object_generic_transform_prop",
|
"AddObjectHelper",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
import mathutils
|
import mathutils
|
||||||
|
|
||||||
from bpy.props import (BoolProperty, FloatVectorProperty)
|
from bpy.props import BoolProperty, FloatVectorProperty
|
||||||
|
|
||||||
|
|
||||||
def add_object_align_init(context, operator):
|
def add_object_align_init(context, operator):
|
||||||
|
Reference in New Issue
Block a user