|
| 1 | +# Copyright 2024 R. Kent James |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# -- Path setup -------------------------------------------------------------- |
| 16 | + |
| 17 | +import sys |
| 18 | + |
| 19 | +from sphinx.ext.autodoc.mock import mock |
| 20 | + |
| 21 | +# -- Project information ----------------------------------------------------- |
| 22 | + |
| 23 | +copyright = 'The <launch_ros> Contributors. License: Apache License 2.0' # noqa A001 |
| 24 | + |
| 25 | +# -- General configuration --------------------------------------------------- |
| 26 | + |
| 27 | +master_doc = 'index' |
| 28 | + |
| 29 | +source_suffix = { |
| 30 | + '.rst': 'restructuredtext', |
| 31 | + '.md': 'markdown', |
| 32 | + '.markdown': 'markdown', |
| 33 | +} |
| 34 | + |
| 35 | +# Add mocks for decorators to prevent rosdoc2 hangs |
| 36 | + |
| 37 | +with mock(['launch']): |
| 38 | + import launch # noqa F401 |
| 39 | + module = sys.modules['launch'] |
| 40 | +sys.modules['launch'] = module |
| 41 | + |
| 42 | +with mock(['launch.frontend']): |
| 43 | + import launch.frontend # noqa F401 |
| 44 | + module = sys.modules['launch.frontend'] |
| 45 | + # These are dummy decorators |
| 46 | + module.expose_action = lambda _: lambda _: _ |
| 47 | + module.expose_substitution = lambda _: lambda _: _ |
| 48 | +sys.modules['launch.frontend'] = module |
| 49 | + |
| 50 | +with mock(['launch.some_substitutions_type']): |
| 51 | + import launch.some_substitutions_type # noqa F401 |
| 52 | + module = sys.modules['launch.some_substitutions_type'] |
| 53 | + module.SomeSubstitutionsType_types_tuple = () |
| 54 | +sys.modules['launch.some_substitutions_type'] = module |
| 55 | + |
| 56 | +# We still want autodoc to mock the base 'launch' module |
| 57 | +sys.modules.pop('launch') |
0 commit comments