Skip to content

Commit d2be9c8

Browse files
committed
Clean up CDP module pages #10
Each module page now has separate sections for types, commands, and events.
1 parent 7ba80e0 commit d2be9c8

2 files changed

Lines changed: 39 additions & 9 deletions

File tree

generator/generate.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828
'''.format(SHARED_HEADER)
2929

3030
MODULE_HEADER = '''{}
31-
32-
\'\'\'
33-
CDP {{}} Domain{{}}
34-
\'\'\'
31+
#
32+
# CDP domain: {{}}{{}}
3533
3634
from __future__ import annotations
3735
from cdp.util import event_class, T_JSON_DICT
@@ -843,12 +841,24 @@ def generate_sphinx(self) -> str:
843841
'''
844842
docs = self.domain + '\n'
845843
docs += '=' * len(self.domain) + '\n\n'
846-
847844
if self.description:
848845
docs += f'{self.description}\n\n'
846+
if self.experimental:
847+
docs += '*This CDP domain is experimental.*\n\n'
848+
docs += f'.. module:: cdp.{self.module}\n\n'
849+
docs += '* Types_\n* Commands_\n* Events_\n\n'
849850

850-
docs += f'.. automodule:: cdp.{self.module}\n'
851-
docs += ' :members:\n'
851+
docs += 'Types\n-----\n'
852+
for type in self.types:
853+
docs += f'\n.. autoclass:: {type.id}\n'
854+
855+
docs += '\nCommands\n--------\n'
856+
for command in sorted(self.commands, key=operator.attrgetter('py_name')):
857+
docs += f'\n.. autofunction:: {command.py_name}\n'
858+
859+
docs += '\nEvents\n------\n'
860+
for event in self.events:
861+
docs += f'\n.. autoclass:: {event.py_name}\n'
852862

853863
return docs
854864

generator/test_generate.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -911,8 +911,28 @@ def test_cdp_domain_sphinx():
911911
912912
This is the animation domain.
913913
914-
.. automodule:: cdp.animation
915-
:members:
914+
*This CDP domain is experimental.*
915+
916+
.. module:: cdp.animation
917+
918+
* Types_
919+
* Commands_
920+
* Events_
921+
922+
Types
923+
-----
924+
925+
.. autoclass:: KeyframeStyle
926+
927+
Commands
928+
--------
929+
930+
.. autofunction:: get_current_time
931+
932+
Events
933+
------
934+
935+
.. autoclass:: AnimationCanceled
916936
""")
917937
domain = CdpDomain.from_json(json_domain)
918938
actual = domain.generate_sphinx()

0 commit comments

Comments
 (0)