Skip to content

Commit f72e557

Browse files
Rémy Baranx (bar)AntoineVDV
Rémy Baranx (bar)
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. closes odoo#1333 Signed-off-by: Antoine Vandevenne (anv) <[email protected]> Co-authored-by: Antoine Vandevenne <[email protected]>
1 parent 405e834 commit f72e557

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

conf.py

+24-18
Original file line numberDiff line numberDiff line change
@@ -58,34 +58,40 @@
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(
70-
f"Could not find Odoo sources directory at {odoo_dir.absolute()}.\n"
71-
f"The 'Developer' documentation will be built but autodoc directives will be skipped.\n"
72-
f"In order to fully build the 'Developer' documentation, clone the repository with "
73-
f"`git clone https://github.com/odoo/odoo` or create a symbolink link."
69+
"Could not find Odoo sources directory in neither of the following folders:\n"
70+
"%(dir_list)s\n"
71+
"The 'Developer' documentation will be built but autodoc directives will be skipped.\n"
72+
"In order to fully build the 'Developer' documentation, clone the repository with "
73+
"`git clone https://github.com/odoo/odoo` or create a symbolic link.",
74+
{'dir_list': '\n'.join([f'\t- {d.resolve()}' for d in odoo_sources_candidate_dirs])},
7475
)
7576
else:
76-
sys.path.insert(0, str(odoo_dir.absolute()))
77+
odoo_dir = odoo_sources_dirs[0].resolve()
78+
sys.path.insert(0, str(odoo_dir))
7779
from odoo import release as odoo_release # Don't collide with Sphinx's 'release' config option
7880
odoo_version = odoo_release.version if 'alpha' not in odoo_release.version else 'master'
7981
if release != odoo_version:
8082
_logger.warning(
81-
f"Found Odoo sources directory but with version '{odoo_version}' incompatible with "
82-
f"documentation version '{version}'.\n"
83-
f"The 'Developer' documentation will be built but autodoc directives will be skipped.\n"
84-
f"In order to fully build the 'Developer' documentation, checkout the matching branch"
85-
f" with `cd odoo && git checkout {version}`."
83+
"Found Odoo sources in %(directory)s but with version '%(odoo_version)s' incompatible "
84+
"with documentation version '%(doc_version)s'.\n"
85+
"The 'Developer' documentation will be built but autodoc directives will be skipped.\n"
86+
"In order to fully build the 'Developer' documentation, checkout the matching branch"
87+
" with `cd odoo && git checkout %(doc_version)s`.",
88+
{'directory': odoo_dir, 'odoo_version': odoo_version, 'doc_version': version},
8689
)
8790
else:
88-
_logger.info(f"Found Odoo sources directory matching documentation version {release}.")
91+
_logger.info(
92+
"Found Odoo sources in %(directory)s matching documentation version '%(version)s'.",
93+
{'directory': odoo_dir, 'version': release},
94+
)
8995
odoo_dir_in_path = True
9096

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

0 commit comments

Comments
 (0)