Skip to content

Commit 9a8dcf9

Browse files
Rémy Baranx (bar)AntoineVDV
andcommitted
[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. X-original-commit: f72e557 Co-authored-by: Antoine Vandevenne <[email protected]>
1 parent afa905b commit 9a8dcf9

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

conf.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@
5858
sys.path.insert(0, str(extension_dir.absolute()))
5959

6060
# Search for the directory of odoo sources to know whether autodoc should be used on the dev doc
61-
odoo_dir = Path('odoo')
61+
odoo_sources_candidate_dirs = (Path('odoo'), Path('../odoo'))
62+
odoo_sources_dirs = [
63+
d for d in odoo_sources_candidate_dirs if d.is_dir() and (d / 'odoo-bin').exists()
64+
]
6265
odoo_dir_in_path = False
63-
if not odoo_dir.is_dir():
64-
parent_odoo_dir = Path('../odoo')
65-
if parent_odoo_dir.is_dir():
66-
_logger.info('Using parent dir to find odoo sources')
67-
odoo_dir = parent_odoo_dir
68-
if not odoo_dir.is_dir():
66+
67+
if not odoo_sources_dirs:
6968
_logger.warning(
69+
<<<<<<< HEAD
7070
f"Could not find Odoo sources directory at {odoo_dir.absolute()}.\n"
7171
f"The 'Developer' documentation will be built but autodoc directives will be skipped.\n"
7272
f"In order to fully build the 'Developer' documentation, clone the repository with "
@@ -78,19 +78,43 @@
7878
# running odoo needs python 3.7 min but monkey patch version_info to be
7979
# able to build the doc in python 3.6
8080
sys.version_info = (3, 7, 0)
81+
=======
82+
"Could not find Odoo sources directory in neither of the following folders:\n"
83+
"%(dir_list)s\n"
84+
"The 'Developer' documentation will be built but autodoc directives will be skipped.\n"
85+
"In order to fully build the 'Developer' documentation, clone the repository with "
86+
"`git clone https://github.com/odoo/odoo` or create a symbolic link.",
87+
{'dir_list': '\n'.join([f'\t- {d.resolve()}' for d in odoo_sources_candidate_dirs])},
88+
)
89+
else:
90+
odoo_dir = odoo_sources_dirs[0].resolve()
91+
sys.path.insert(0, str(odoo_dir))
92+
>>>>>>> cadc205c... temp
8193
from odoo import release as odoo_release # Don't collide with Sphinx's 'release' config option
8294
odoo_version = odoo_release.version.replace('~', '-') \
8395
if 'alpha' not in odoo_release.version else 'master'
8496
if release != odoo_version:
8597
_logger.warning(
98+
<<<<<<< HEAD
8699
f"Found Odoo sources directory but with version '{odoo_version}' incompatible with "
87100
f"documentation version '{version}'.\n"
88101
f"The 'Developer' documentation will be built but autodoc directives will be skipped.\n"
89102
f"In order to fully build the 'Developer' documentation, checkout the matching branch "
90103
f"with `cd odoo && git checkout {version}`."
104+
=======
105+
"Found Odoo sources in %(directory)s but with version '%(odoo_version)s' incompatible "
106+
"with documentation version '%(doc_version)s'.\n"
107+
"The 'Developer' documentation will be built but autodoc directives will be skipped.\n"
108+
"In order to fully build the 'Developer' documentation, checkout the matching branch"
109+
" with `cd odoo && git checkout %(doc_version)s`.",
110+
{'directory': odoo_dir, 'odoo_version': odoo_version, 'doc_version': version},
111+
>>>>>>> cadc205c... temp
91112
)
92113
else:
93-
_logger.info(f"Found Odoo sources directory matching documentation version {release}.")
114+
_logger.info(
115+
"Found Odoo sources in %(directory)s matching documentation version '%(version)s'.",
116+
{'directory': odoo_dir, 'version': release},
117+
)
94118
odoo_dir_in_path = True
95119

96120
# The Sphinx extensions to use, as module names.

0 commit comments

Comments
 (0)