Generate a Sphinx document for this domain.
(self)
| 857 | return code |
| 858 | |
| 859 | def generate_sphinx(self): |
| 860 | """Generate a Sphinx document for this domain.""" |
| 861 | docs = self.domain + "\n" |
| 862 | docs += "=" * len(self.domain) + "\n\n" |
| 863 | if self.description: |
| 864 | docs += f"{self.description}\n\n" |
| 865 | if self.experimental: |
| 866 | docs += "*This CDP domain is experimental.*\n\n" |
| 867 | docs += f".. module:: cdp.{self.module}\n\n" |
| 868 | docs += "* Types_\n* Commands_\n* Events_\n\n" |
| 869 | |
| 870 | docs += "Types\n-----\n\n" |
| 871 | if self.types: |
| 872 | docs += dedent("""\ |
| 873 | Generally, you do not need to instantiate CDP types |
| 874 | yourself. Instead, the API creates objects for you as return |
| 875 | values from commands, and then you can use those objects as |
| 876 | arguments to other commands. |
| 877 | """) |
| 878 | else: |
| 879 | docs += "*There are no types in this module.*\n" |
| 880 | for type in self.types: |
| 881 | docs += f"\n.. autoclass:: {type.id}\n" |
| 882 | docs += " :members:\n" |
| 883 | docs += " :undoc-members:\n" |
| 884 | docs += " :exclude-members: from_json, to_json\n" |
| 885 | |
| 886 | docs += "\nCommands\n--------\n\n" |
| 887 | if self.commands: |
| 888 | docs += dedent("""\ |
| 889 | Each command is a generator function. The return |
| 890 | type ``Generator[x, y, z]`` indicates that the generator |
| 891 | *yields* arguments of type ``x``, it must be resumed with |
| 892 | an argument of type ``y``, and it returns type ``z``. In |
| 893 | this library, types ``x`` and ``y`` are the same for all |
| 894 | commands, and ``z`` is the return type you should pay attention |
| 895 | to. For more information, see |
| 896 | :ref:`Getting Started: Commands <getting-started-commands>`. |
| 897 | """) |
| 898 | else: |
| 899 | docs += "*There are no types in this module.*\n" |
| 900 | for command in sorted(self.commands, key=operator.attrgetter("py_name")): |
| 901 | docs += f"\n.. autofunction:: {command.py_name}\n" |
| 902 | |
| 903 | docs += "\nEvents\n------\n\n" |
| 904 | if self.events: |
| 905 | docs += dedent("""\ |
| 906 | Generally, you do not need to instantiate CDP events |
| 907 | yourself. Instead, the API creates events for you and then |
| 908 | you use the event\'s attributes. |
| 909 | """) |
| 910 | else: |
| 911 | docs += "*There are no events in this module.*\n" |
| 912 | for event in self.events: |
| 913 | docs += f"\n.. autoclass:: {event.py_name}\n" |
| 914 | docs += " :members:\n" |
| 915 | docs += " :undoc-members:\n" |
| 916 | docs += " :exclude-members: from_json, to_json\n" |