Skip to content

refactor: applied bug fixes and code refactor from #55 #64

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

Merged
merged 2 commits into from
Aug 8, 2024

Conversation

ovflowd
Copy link
Member

@ovflowd ovflowd commented Aug 7, 2024

Description

This PR incorporates the code refactors and bug fixes introduced from #55 into the codebase, splitting the actual generator changes done in #55 from the plain bug fixes and code refactors.

Refactors:

  • Move remark imports and remark logic (for crating processors) to a dedicated remark.mjs file
  • Updated ESLint config to be "namespace"
  • Export the common types into a global namespace, to prevent unnecessary repeated JSdoc type imports and typedefs
  • Updated some imports to by type imports whenever possible
  • Reordered imports using default import sorter
  • Support multiple stability index entries per section, instead of just one.
  • Merge metadata update entries into changes by mapping the update entries into the same format used by changes within metadata.mjs
  • Better types for WithJSON and for the Stability Index entries

Bug Fixes

  • Fixed parser excluding the last node when on the last section of the document
  • Fixed specific metadata entries being lost since they were not being merged
  • Fixed incorrect mapping of DOC_TYPES_MAPPING_OTHER on the utils/parsers.mjs
  • Moved type link replacement to be done outside of the AST process.

Validation

The json-simple generator should still work as expected

@ovflowd ovflowd requested a review from a team as a code owner August 7, 2024 11:44
@ovflowd
Copy link
Member Author

ovflowd commented Aug 7, 2024

cc @nodejs/web-infra can we get this reviewed asap, so I can merge it against main and rebase the branch on #55 to keep working on the legacy-html generator?

@ovflowd
Copy link
Member Author

ovflowd commented Aug 7, 2024

cc @JakobJingleheimer here's the PR only containing the bug fixes against main and code refactors.

@canerakdas
Copy link
Member

@ovflowd When I checked the output of the main branch and refactor/bug-fixes-and-updated-code, there is a difference like the following;

- MyObject::MyObject(double value) : value_(value) {\n}\n\n
+ MyObject::MyObject(double value) : value_(value) \n\n\n

Looks like the curly brackets have been removed 🤔


I checked with the command below;

npx api-docs-tooling -i PATH_TO_NODE/doc/api/addons.md -t json-simple -o .

@ovflowd
Copy link
Member Author

ovflowd commented Aug 7, 2024

@ovflowd When I checked the output of the main branch and refactor/bug-fixes-and-updated-code, there is a difference like the following;

- MyObject::MyObject(double value) : value_(value) {\n}\n\n
+ MyObject::MyObject(double value) : value_(value) \n\n\n

Looks like the curly brackets have been removed 🤔

I checked with the command below;

npx api-docs-tooling -i PATH_TO_NODE/doc/api/addons.md -t json-simple -o .

Can you give more examples? I'd say the 2nd one looks better. 🤔

@canerakdas
Copy link
Member

@ovflowd When I checked the output of the main branch and refactor/bug-fixes-and-updated-code, there is a difference like the following;

- MyObject::MyObject(double value) : value_(value) {\n}\n\n
+ MyObject::MyObject(double value) : value_(value) \n\n\n

Looks like the curly brackets have been removed 🤔
I checked with the command below;

npx api-docs-tooling -i PATH_TO_NODE/doc/api/addons.md -t json-simple -o .

Can you give more examples? I'd say the 2nd one looks better. 🤔

For example, there is a code like this on the same page;

MyObject::~MyObject() {

}

It looks like we are taking this code and converting it to the following version;

MyObject::~MyObject()

Current HTML output;

image

You can also check the current JSON output on this page; (MyObject::~MyObject())

@ovflowd
Copy link
Member Author

ovflowd commented Aug 7, 2024

Ah, I see.

@ovflowd
Copy link
Member Author

ovflowd commented Aug 7, 2024

I found the issue. It was a bug already on the existing main, but since the previous code was not working correctly, the symptoms appeared now. It's a silly thing.

Good to always compare the content from the current JSON on nodejs.org versus what we generate

@canerakdas
Copy link
Member

I found the issue. It was a bug already on the existing main, but since the previous code was not working correctly, the symptoms appeared now. It's a silly thing.

Good to always compare the content from the current JSON on nodejs.org versus what we generate

Thank you, it looks fixed 🎉

I will continue to compare outputs until our tests are ready and cover this kind of situation 😄

Copy link
Member

@canerakdas canerakdas left a comment

Choose a reason for hiding this comment

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

LGTM :shipit:

@ovflowd ovflowd merged commit 443f2c7 into main Aug 8, 2024
6 checks passed
@ovflowd ovflowd deleted the refactor/bug-fixes-and-updated-code branch August 8, 2024 09:00
@ovflowd
Copy link
Member Author

ovflowd commented Aug 8, 2024

I found the issue. It was a bug already on the existing main, but since the previous code was not working correctly, the symptoms appeared now. It's a silly thing.
Good to always compare the content from the current JSON on nodejs.org versus what we generate

Thank you, it looks fixed 🎉

I will continue to compare outputs until our tests are ready and cover this kind of situation 😄

Feel free to add unit tests to the existing methods we have here (to complement @AugustinMauroy's ones). If @AugustinMauroy can add more tests on a follow-up PR from your original PR, that would also be great.

We want to unit-test a whole section of Markdown and have snapshots. Feel free to copy sections containing unique things from different /docs/api/*.md files, put them together in one file and snapshot the toJSON() version.

Also feel free to add tests for the functionality underneath queries.mjs, and the other utils.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants