get list of C functions/structs/etc...

17 views
Skip to first unread message

Matias v01d

unread,
Sep 11, 2020, 11:16:38 AM9/11/20
to sphinx-users
Hi,
we're using Sphinx to document a C interface. I would like to get a list of all documented functions, structs, types, etc, generated and output
to a file in YAML/JSON or similar in order to use this to automatically check API stability by comparing to previous releases.
Is this possible somehow?

Thanks,
Matias

Komiya Takeshi

unread,
Sep 12, 2020, 12:30:30 PM9/12/20
to sphinx...@googlegroups.com
Hi,

There is no such feature. You need to write a code to extract data from Sphinx.

This is an example code to get the list of C objects. Please append
this into your conf.py.
```
def on_env_check_consistency(app, env):
domain = env.get_domain('c')
for c_object in domain.get_objects():
print(c_object)


def setup(app):
app.connect('env-check-consistency', on_env_check_consistency)
```

Note: This hooks "env-check-consistency" event and get C objects from C domain.
For more details, please read developers reference:
* https://www.sphinx-doc.org/en/master/extdev/index.html
* https://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx-core-events
* https://www.sphinx-doc.org/en/master/extdev/domainapi.html#sphinx.domains.Domain.get_objects

Thanks,
Takeshi KOMIYA

2020年9月12日(土) 0:16 Matias v01d <mat...@imap.cc>:
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/62f3be60-dc02-4325-a33c-0ec973f0c104o%40googlegroups.com.

Matias v01d

unread,
Sep 12, 2020, 6:05:24 PM9/12/20
to sphinx-users
Thank you for your reply! I tried the code and I get output like this:

('pthread_attr_init', 'pthread_attr_init', 'function', 'reference/user/08_pthread', 'c.pthread_attr_init', 1)

I'm interested in obtaining the full declaration for this function passed in the rst, so I can compare the function
signature exactly. Is it possible to obtain this? From the documentation it doesn't seem this object carries this information.

Best,
Matias

Daniel Scott

unread,
Nov 25, 2020, 10:31:47 PM11/25/20
to sphinx...@googlegroups.com
--
Reply all
Reply to author
Forward
0 new messages