[FIX] conf.py: check odoo_dir is a real Odoo sources dir
In `conf.py`, we try to find a Odoo sources folder among `odoo` and
`../odoo` directories without really checking that they really are
Odoo sources folders, leading to doc generation error if it's not the case.
So, to improve that, this commit checks that the selected Odoo sources folder
contains `odoo-bin`.
While we're at it, the logging is also improved to always display the
matching odoo sources' folder and version.
closes odoo/documentation#1340
X-original-commit: f72e557f2c
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Co-authored-by: Antoine Vandevenne <anv@odoo.com>
This commit is contained in:
parent
afa905b9c4
commit
57e1e31433
47
conf.py
47
conf.py
@ -58,39 +58,44 @@ extension_dir = Path('extensions')
|
|||||||
sys.path.insert(0, str(extension_dir.absolute()))
|
sys.path.insert(0, str(extension_dir.absolute()))
|
||||||
|
|
||||||
# Search for the directory of odoo sources to know whether autodoc should be used on the dev doc
|
# Search for the directory of odoo sources to know whether autodoc should be used on the dev doc
|
||||||
odoo_dir = Path('odoo')
|
odoo_sources_candidate_dirs = (Path('odoo'), Path('../odoo'))
|
||||||
|
odoo_sources_dirs = [
|
||||||
|
d for d in odoo_sources_candidate_dirs if d.is_dir() and (d / 'odoo-bin').exists()
|
||||||
|
]
|
||||||
odoo_dir_in_path = False
|
odoo_dir_in_path = False
|
||||||
if not odoo_dir.is_dir():
|
|
||||||
parent_odoo_dir = Path('../odoo')
|
if not odoo_sources_dirs:
|
||||||
if parent_odoo_dir.is_dir():
|
|
||||||
_logger.info('Using parent dir to find odoo sources')
|
|
||||||
odoo_dir = parent_odoo_dir
|
|
||||||
if not odoo_dir.is_dir():
|
|
||||||
_logger.warning(
|
_logger.warning(
|
||||||
f"Could not find Odoo sources directory at {odoo_dir.absolute()}.\n"
|
"Could not find Odoo sources directory in neither of the following folders:\n"
|
||||||
f"The 'Developer' documentation will be built but autodoc directives will be skipped.\n"
|
"%(dir_list)s\n"
|
||||||
f"In order to fully build the 'Developer' documentation, clone the repository with "
|
"The 'Developer' documentation will be built but autodoc directives will be skipped.\n"
|
||||||
f"`git clone https://github.com/odoo/odoo` or create a symbolic link."
|
"In order to fully build the 'Developer' documentation, clone the repository with "
|
||||||
|
"`git clone https://github.com/odoo/odoo` or create a symbolic link.",
|
||||||
|
{'dir_list': '\n'.join([f'\t- {d.resolve()}' for d in odoo_sources_candidate_dirs])},
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
sys.path.insert(0, str(odoo_dir.absolute()))
|
odoo_dir = odoo_sources_dirs[0].resolve()
|
||||||
if sys.version_info < (3, 7) and sys.version_info > (3, 6):
|
sys.path.insert(0, str(odoo_dir))
|
||||||
# running odoo needs python 3.7 min but monkey patch version_info to be
|
if (3, 6) < sys.version_info < (3, 7):
|
||||||
# able to build the doc in python 3.6
|
# Running odoo needs python 3.7 min but monkey patch version_info to be compatible with 3.6
|
||||||
sys.version_info = (3, 7, 0)
|
sys.version_info = (3, 7, 0)
|
||||||
from odoo import release as odoo_release # Don't collide with Sphinx's 'release' config option
|
from odoo import release as odoo_release # Don't collide with Sphinx's 'release' config option
|
||||||
odoo_version = odoo_release.version.replace('~', '-') \
|
odoo_version = odoo_release.version.replace('~', '-') \
|
||||||
if 'alpha' not in odoo_release.version else 'master'
|
if 'alpha' not in odoo_release.version else 'master'
|
||||||
if release != odoo_version:
|
if release != odoo_version:
|
||||||
_logger.warning(
|
_logger.warning(
|
||||||
f"Found Odoo sources directory but with version '{odoo_version}' incompatible with "
|
"Found Odoo sources in %(directory)s but with version '%(odoo_version)s' incompatible "
|
||||||
f"documentation version '{version}'.\n"
|
"with documentation version '%(doc_version)s'.\n"
|
||||||
f"The 'Developer' documentation will be built but autodoc directives will be skipped.\n"
|
"The 'Developer' documentation will be built but autodoc directives will be skipped.\n"
|
||||||
f"In order to fully build the 'Developer' documentation, checkout the matching branch "
|
"In order to fully build the 'Developer' documentation, checkout the matching branch"
|
||||||
f"with `cd odoo && git checkout {version}`."
|
" with `cd odoo && git checkout %(doc_version)s`.",
|
||||||
|
{'directory': odoo_dir, 'odoo_version': odoo_version, 'doc_version': version},
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
_logger.info(f"Found Odoo sources directory matching documentation version {release}.")
|
_logger.info(
|
||||||
|
"Found Odoo sources in %(directory)s matching documentation version '%(version)s'.",
|
||||||
|
{'directory': odoo_dir, 'version': release},
|
||||||
|
)
|
||||||
odoo_dir_in_path = True
|
odoo_dir_in_path = True
|
||||||
|
|
||||||
# The Sphinx extensions to use, as module names.
|
# The Sphinx extensions to use, as module names.
|
||||||
|
Loading…
Reference in New Issue
Block a user