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

[WIP] Preliminary support for the C API in the MDX pipeline #2767

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

arnaucasau
Copy link
Collaborator

@arnaucasau arnaucasau commented Mar 12, 2025

This PR adds support for the Qiskit SDK C API in our MDX pipeline.

For the moment, we are using the python Function and Class components to represent the C functions and structs respectively.

I generated the docs by running:

npm run gen-api -- -p qiskit-c -v 2.0.0

Comment on lines +228 to +239
function buildCApiFunction(h: H, node: any) {
// We use the first child as the signature
node.properties.signature = toText(node.children[0]).trim();
node.children = node.children.splice(1, 1);

// We use the Function component for C functions
node.tagName = "function";

return buildApiComponent(h, node);
}

function buildCApiStruct(h: H, node: any) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I divided it into two functions because I think the implementation of functions and structs will diverge when handling all the edge cases.

): void {
const modulePrefix = "module-";
const modulePrefix = isCApi ? "group__" : "module-";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I kept the meta.apiType as module because in my opinion it is strange to have the apiType as group when a single file contains several groups on it. In addition we want the same behavior in the TOC as the python modules

@@ -112,6 +110,7 @@ async function convertFilesToMarkdown(
imageDestination: pkg.outputDir("/images"),
releaseNotesTitle: pkg.releaseNotesTitle(),
hasSeparateReleaseNotes: pkg.hasSeparateReleaseNotes(),
isCApi: pkg.language == "C",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This parameter is useful to handle some C API specifics that we don't want for our Python APIs

@arnaucasau
Copy link
Collaborator Author

Moving to a draft to explore an alternative to generate functions and structs that it occurred to me and that could make the changes cleaner and easy to maintain.

@arnaucasau arnaucasau marked this pull request as draft March 12, 2025 18:23
@arnaucasau arnaucasau changed the title Preliminary support for the C API in the MDX pipeline [WIP] Preliminary support for the C API in the MDX pipeline Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant