Skip to content

Commit

Permalink
Give precedence to rosdoc2 settings when building
Browse files Browse the repository at this point in the history
Specifically for the `python_source` setting, which must be considered
first to generate `package_src_directory`.

Signed-off-by: Abrar Rahman Protyasha <[email protected]>
  • Loading branch information
Abrar Rahman Protyasha committed Aug 11, 2021
1 parent e43f3ab commit 2bbdc87
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions rosdoc2/verbs/build/builders/sphinx_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,15 +393,23 @@ def build(self, *, doc_build_folder, output_staging_directory):
if (self.build_context.build_type == 'ament_python' or
self.build_context.run_sphinx_apidoc):
package_xml_directory = os.path.dirname(self.build_context.package.filename)
package_list = setuptools.find_packages(where=package_xml_directory)
if package_list:
package_src_directory = os.path.join(package_xml_directory, package_list[0])
elif self.build_context.python_source is not None:
# If 'python_source' is specified, construct 'package_src_directory' from it
if self.build_context.python_source is not None:
package_src_directory = \
os.path.join(
package_xml_directory,
self.build_context.python_source)
# If not provided, try to find the package source direcotry
else:
package_list = setuptools.find_packages(where=package_xml_directory)
try:
package_src_directory = \
os.path.join(
package_xml_directory,
package_list[package_list.index(self.build_context.package.name))]
except ValueError:
package_src_directory = ''
if not package_src_directory:
msg = \
'Could not locate source directory to invoke sphinx-apidoc in. ' \
'If this is package does not have a standard Python package layout, '\
Expand Down

0 comments on commit 2bbdc87

Please sign in to comment.