Skip to content

Commit 39ac8f8

Browse files
Include the C extension when generating API docs (#126)
### Motivation #85 (comment) Some targets in the API docs are referenced from the `_pulsar` module, while the `pydoctor` command does not generate API docs for it. It's not friendly to users, e.g. they cannot find which values could `_pulsar.ConsumerType` be. ``` pulsar/__init__.py:695: Cannot find link target for "_pulsar.ConsumerType" ``` ### Modifications Fix the documents to describe how to include the API docs for the `_pulsar` module when generating API docs. It also fixes some other warnings when running the `pydoctor` command.
1 parent d2fac8f commit 39ac8f8

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,22 @@ python3 ./tests/pulsar_test.py 'PulsarTest.test_tls_auth'
109109

110110
## Generate API docs
111111

112-
Pulsar Python Client uses [pydoctor](https://github.com/twisted/pydoctor) to generate API docs. To generate by yourself, run the following command in the root path of this repository:
112+
Pulsar Python Client uses [pydoctor](https://github.com/twisted/pydoctor) to generate API docs. To generate by yourself, you need to install the Python library first. Then run the following command in the root path of this repository:
113113

114114
```bash
115115
sudo python3 -m pip install pydoctor
116+
cp $(python3 -c 'import _pulsar, os; print(_pulsar.__file__)') ./_pulsar.so
116117
pydoctor --make-html \
117-
--html-viewsource-base=https://github.com/apache/pulsar-client-python/tree/<release-version-tag> \
118118
--docformat=numpy --theme=readthedocs \
119119
--intersphinx=https://docs.python.org/3/objects.inv \
120120
--html-output=<path-to-apidocs> \
121+
--introspect-c-modules \
122+
./_pulsar.so \
121123
pulsar
122124
```
123125

126+
Then the index page will be generated in `<path-to-apidocs>/index.html`.
127+
124128
## Contribute
125129

126130
We welcome contributions from the open source community!

RELEASE.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,15 @@ git checkout vX.Y.0
225225
# It's better to replace this URL with the URL of your own fork
226226
git clone [email protected]:apache/pulsar-site.git
227227
sudo python3 -m pip install pydoctor
228+
cp $(python3 -c 'import _pulsar, os; print(_pulsar.__file__)') ./_pulsar.so
228229
pydoctor --make-html \
229230
--html-viewsource-base=https://github.com/apache/pulsar-client-python/tree/vX.Y.0 \
230231
--docformat=numpy --theme=readthedocs \
231232
--intersphinx=https://docs.python.org/3/objects.inv \
232233
--html-output=./pulsar-site/site2/website-next/static/api/python/X.Y.x \
233-
pulsar-client-python/pulsar
234+
--introspect-c-modules \
235+
./_pulsar.so \
236+
pulsar
234237
cd pulsar-site
235238
git checkout -b py-docs-X.Y
236239
git add .

pulsar/__init__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@ def create_producer(self, topic,
575575
576576
Supported modes:
577577
578-
* `PartitionsRoutingMode.RoundRobinDistribution`
579-
* `PartitionsRoutingMode.UseSinglePartition`.
578+
* ``PartitionsRoutingMode.RoundRobinDistribution``
579+
* ``PartitionsRoutingMode.UseSinglePartition``
580580
lazy_start_partitioned_producers: bool, default=False
581581
This config affects producers of partitioned topics only. It controls whether producers register
582582
and connect immediately to the owner broker of each partition or start lazily on demand. The internal
@@ -751,7 +751,7 @@ def my_listener(consumer, message):
751751
Periods of seconds for consumer to auto discover match topics.
752752
initial_position: InitialPosition, default=InitialPosition.Latest
753753
Set the initial position of a consumer when subscribing to the topic.
754-
It could be either: `InitialPosition.Earliest` or `InitialPosition.Latest`.
754+
It could be either: ``InitialPosition.Earliest`` or ``InitialPosition.Latest``.
755755
crypto_key_reader: CryptoKeyReader, optional
756756
Symmetric encryption class implementation, configuring public key encryption messages for the producer
757757
and private key decryption messages for the consumer
@@ -1304,14 +1304,13 @@ def acknowledge(self, message):
13041304
13051305
Parameters
13061306
----------
1307-
1308-
message:
1307+
message : Message, _pulsar.Message, _pulsar.MessageId
13091308
The received message or message id.
13101309
13111310
Raises
13121311
------
13131312
OperationNotSupported
1314-
if `message` is not allowed to acknowledge
1313+
if ``message`` is not allowed to acknowledge
13151314
"""
13161315
if isinstance(message, Message):
13171316
self._consumer.acknowledge(message._message)

0 commit comments

Comments
 (0)