Skip to content

Commit

Permalink
add more default configuration to sphinx conf.py
Browse files Browse the repository at this point in the history
Add values extracted from package.xml to the wrapping sphinx config.py. This eliminates the need for packages with custom config.py to duplicate author, copyright and version information from package.xml.
  • Loading branch information
ottojo committed Feb 16, 2024
1 parent 5c52cf3 commit 225c6c3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion rosdoc2/verbs/build/builders/sphinx_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import datetime
import json
import logging
import os
Expand Down Expand Up @@ -72,6 +73,10 @@ def ensure_global(name, default):
ensure_global('rosdoc2_settings', {{}})
ensure_global('extensions', [])
ensure_global('project', "{package_name}")
ensure_global('copyright', "{year}, {package_licenses}")
ensure_global('author', "{package_authors}")
ensure_global('release', "{package.version}")
if rosdoc2_settings.get('enable_autodoc', True):
print('[rosdoc2] enabling autodoc', file=sys.stderr)
Expand Down Expand Up @@ -643,7 +648,13 @@ def generate_wrapping_rosdoc2_sphinx_project_into_directory(
'user_conf_py_filename': esc_backslash(
os.path.abspath(os.path.join(user_sourcedir, 'conf.py'))),
'breathe_projects': ',\n'.join(breathe_projects) + '\n ',
'intersphinx_mapping_extensions': ',\n '.join(intersphinx_mapping_extensions)
'intersphinx_mapping_extensions': ',\n '.join(intersphinx_mapping_extensions),
'year': datetime.date.today().year,
'package_licenses': ', '.join(package.licenses),
'package_authors': ', '.join(set(
[a.name for a in package.authors] + [m.name for m in package.maintainers]
)),
'package': package,
}

print(os.path.abspath(os.path.join(directory, 'conf.py')))
Expand Down

0 comments on commit 225c6c3

Please sign in to comment.