Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C domain rewrite #7319

Merged
merged 12 commits into from Mar 17, 2020
Merged

C domain rewrite #7319

merged 12 commits into from Mar 17, 2020

Conversation

jakobandersen
Copy link
Contributor

Subject: essentially a rewrite of the C domain to fix issues and enable further development

Feature or Bugfix

  • Feature
  • Bugfix
  • Refactoring

Purpose

The original implementation of the C domain relied on regex matching to parse signatures. While it works for many cases, there is a limit. This rewrite is in the same style as the C++ domain, and some details are shared between the two domains. It is naturally a large breaking change, but I believe it is necessary for furture improvement of the domain. In order to make some simple kind of judgement of the changes I have updated the cpython documentation as best as possible: https://github.com/jakobandersen/cpython/tree/doc_fixes

  • xref lookup now respects the scope that it was declared in.
  • Anonymous entities can now be declared with appropriate lookup rules.
  • The c:type directive seemed to have been a catch-all for many signatures which made it difficult to parse and generate appropriate output. It has been changed to be much stricter and only allow either a name or a typedef-like declaration.
  • There are new directives for structs, unions, enums, and enumerators. Lookup rules for enumerators are as expected from the language.
  • New xref roles has been added in conjunction with the directives. (The issue from py domain: All :py:* roles can refer python objects even if objtype not matched. #7243 is not yet fixed yet)
  • An c:expr role has been added to typeset a type of an expression in text. In particular while one before could write ... a :c:type:`int` and then ... or ... a :c:type:`char*` and then ... this will now trigger an error as the c:type strictly is for cross-referencing. Instead one should use the c:expr role.
  • This PR incidentally reverts PR c domain: Generate node_id for objects in the right way #7269 (sorry), except the removal of the signode['names'].append(targetname) thing. However, the ID generation is now guaranteed to produce different IDs for different declarations, and they are produced from parsed input (i.e., no arbitrary code injection).

Detail

@jakobandersen jakobandersen added type:bug type:enhancement enhance or introduce a new feature domains:c labels Mar 15, 2020
@jakobandersen jakobandersen added this to the 3.0.0 milestone Mar 15, 2020
@jakobandersen jakobandersen self-assigned this Mar 15, 2020
Copy link
Member

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortuantely, I don't have time to understand the new implementation of the C domain. But it would go well because you're author :-) +1 for merging.

sphinx/domains/c.py Show resolved Hide resolved
sphinx/domains/c.py Outdated Show resolved Hide resolved
@jakobandersen jakobandersen merged commit 385f7ed into sphinx-doc:3.x Mar 17, 2020
@jakobandersen jakobandersen deleted the c_revamp branch March 17, 2020 09:19
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
domains:c type:bug type:enhancement enhance or introduce a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using regular expressions for c function prototypes Structure members break, when accompanied with brackets
3 participants