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

Use early returns for sphinxHtmlToMarkdown member processing #590

Merged

Conversation

arnaucasau
Copy link
Collaborator

@arnaucasau arnaucasau commented Jan 5, 2024

This PR is a follow-up from #584.

None of the logic is changed, only the control flow. This uses early returns to make it more clear how each distinct API type is handled. It also DRYs this code:

        const priorPythonApiType = meta.python_api_type;
        if (!priorPythonApiType) {
          meta.python_api_type = python_type;
          meta.python_api_name = id;
        }

@Eric-Arellano Eric-Arellano changed the title Refactor sphinxHtmlToMarkdown recursive members Use early returns for sphinxHtmlToMarkdown member processing Jan 8, 2024
@Eric-Arellano Eric-Arellano marked this pull request as ready for review January 8, 2024 14:53
Copy link
Member

@frankharkins frankharkins left a comment

Choose a reason for hiding this comment

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

Thanks! Big improvement IMO, I find the new code much easier to read 🚀

If you haven't already, can you regenerate the current API docs to check they stay the same?

}

return `<div>${$child.html()}</div>`;
throw new Error(`Unhandled Python type: ${python_type}`);
Copy link
Member

Choose a reason for hiding this comment

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

Nice

@Eric-Arellano Eric-Arellano added this pull request to the merge queue Jan 8, 2024
Merged via the queue into Qiskit:main with commit 56a9c72 Jan 8, 2024
2 checks passed
github-actions bot pushed a commit that referenced this pull request Jan 9, 2024
This PR is a follow-up from #584.

None of the logic is changed, only the control flow. This uses early
returns to make it more clear how each distinct API type is handled. It
also DRYs this code:

```typescript
        const priorPythonApiType = meta.python_api_type;
        if (!priorPythonApiType) {
          meta.python_api_type = python_type;
          meta.python_api_name = id;
        }
```

---------

Co-authored-by: Eric Arellano <[email protected]>
frankharkins pushed a commit to frankharkins/documentation that referenced this pull request Jul 22, 2024
)

This PR is a follow-up from Qiskit#584.

None of the logic is changed, only the control flow. This uses early
returns to make it more clear how each distinct API type is handled. It
also DRYs this code:

```typescript
        const priorPythonApiType = meta.python_api_type;
        if (!priorPythonApiType) {
          meta.python_api_type = python_type;
          meta.python_api_name = id;
        }
```

---------

Co-authored-by: Eric Arellano <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants