|
58 | 58 | sys.path.insert(0, str(extension_dir.absolute()))
|
59 | 59 |
|
60 | 60 | # 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 | +] |
62 | 65 | 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: |
69 | 68 | _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 symbolic 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])}, |
74 | 75 | )
|
75 | 76 | else:
|
76 |
| - sys.path.insert(0, str(odoo_dir.absolute())) |
77 |
| - if sys.version_info < (3, 7) and sys.version_info > (3, 6): |
78 |
| - # running odoo needs python 3.7 min but monkey patch version_info to be |
79 |
| - # able to build the doc in python 3.6 |
| 77 | + odoo_dir = odoo_sources_dirs[0].resolve() |
| 78 | + sys.path.insert(0, str(odoo_dir)) |
| 79 | + if (3, 6) < sys.version_info < (3, 7): |
| 80 | + # Running odoo needs python 3.7 min but monkey patch version_info to be compatible with 3.6 |
80 | 81 | sys.version_info = (3, 7, 0)
|
81 | 82 | from odoo import release as odoo_release # Don't collide with Sphinx's 'release' config option
|
82 | 83 | odoo_version = odoo_release.version.replace('~', '-') \
|
83 | 84 | if 'alpha' not in odoo_release.version else 'master'
|
84 | 85 | if release != odoo_version:
|
85 | 86 | _logger.warning(
|
86 |
| - f"Found Odoo sources directory but with version '{odoo_version}' incompatible with " |
87 |
| - f"documentation version '{version}'.\n" |
88 |
| - f"The 'Developer' documentation will be built but autodoc directives will be skipped.\n" |
89 |
| - f"In order to fully build the 'Developer' documentation, checkout the matching branch " |
90 |
| - f"with `cd odoo && git checkout {version}`." |
| 87 | + "Found Odoo sources in %(directory)s but with version '%(odoo_version)s' incompatible " |
| 88 | + "with documentation version '%(doc_version)s'.\n" |
| 89 | + "The 'Developer' documentation will be built but autodoc directives will be skipped.\n" |
| 90 | + "In order to fully build the 'Developer' documentation, checkout the matching branch" |
| 91 | + " with `cd odoo && git checkout %(doc_version)s`.", |
| 92 | + {'directory': odoo_dir, 'odoo_version': odoo_version, 'doc_version': version}, |
91 | 93 | )
|
92 | 94 | else:
|
93 |
| - _logger.info(f"Found Odoo sources directory matching documentation version {release}.") |
| 95 | + _logger.info( |
| 96 | + "Found Odoo sources in %(directory)s matching documentation version '%(version)s'.", |
| 97 | + {'directory': odoo_dir, 'version': release}, |
| 98 | + ) |
94 | 99 | odoo_dir_in_path = True
|
95 | 100 |
|
96 | 101 | # The Sphinx extensions to use, as module names.
|
|
0 commit comments