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

Refactor/parseutil #1022

Merged
merged 11 commits into from
Dec 20, 2023
Merged

Refactor/parseutil #1022

merged 11 commits into from
Dec 20, 2023

Conversation

zorkow
Copy link
Member

@zorkow zorkow commented Nov 16, 2023

Refactors the ParseUtil module:

  • Makes a Map out of unit conversion mapping and exports it. This makes it extensible
  • Adapts all other constants to use the extensible map. (This is useful for the IEEE where they have a custom unit pi).
  • Does not (yet) combine length functionality with the util/lengths.ts module (see my email from yesterday).
  • Removes namespace and adapts all import statements in modules using ParseUtil. This is the majority of files!
  • Adds some tests for this for all the length methods, that I have used during conversion. Note, these already uses pnpm. To run the tests, do
pnpm -r install
pnpm test

The tests are in a separate commit and can be removed.

@zorkow zorkow requested a review from dpvc November 16, 2023 12:11
@zorkow
Copy link
Member Author

zorkow commented Nov 16, 2023

Since the indentation has changed on ParseUtil.ts it is best viewed with ignore whitespace.

@dpvc dpvc added this to the v4.0 milestone Nov 20, 2023
Copy link
Member

@dpvc dpvc left a comment

Choose a reason for hiding this comment

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

Overall, a good move. I have a few comments in a couple of areas, however. See what you think.

tests/package.json Outdated Show resolved Hide resolved
ts/input/tex/ParseUtil.ts Outdated Show resolved Hide resolved
ts/input/tex/ParseUtil.ts Show resolved Hide resolved
ts/input/tex/ParseUtil.ts Outdated Show resolved Hide resolved
@zorkow
Copy link
Member Author

zorkow commented Nov 27, 2023

@dpvc I've refactored the ParseUtil into a single object. Have a look, if that is really what you want.

The UNIT_CASES is now a bespoke class that can be used for similar mappings in lengths.
And there are a number of temporary elements, that should eventually move into lenghts.

@zorkow
Copy link
Member Author

zorkow commented Nov 27, 2023

Also should this here

if (Math.abs(m) < .001) return '0';

not return 0em. The rounding function below does that. Then it would be the same as Em in ParseUtil.ts

Copy link
Member

@dpvc dpvc left a comment

Choose a reason for hiding this comment

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

See my comments below about the ParseUtil object.

ts/input/tex/ParseUtil.ts Outdated Show resolved Hide resolved
ts/input/tex/ParseUtil.ts Outdated Show resolved Hide resolved
@zorkow
Copy link
Member Author

zorkow commented Nov 28, 2023

I've created the single ParseUtil object now, making sure that only the previously exported methods are contained. I've did some caml case renaming as well.
PTAL.

Base automatically changed from pnpm_move to develop November 28, 2023 11:17
@zorkow
Copy link
Member Author

zorkow commented Dec 6, 2023

@dpvc If I understand correctly, you want to be able to make changes to ParseUtil functionality from the configuration options. How should be deal with this when (or if) we combine ParseUtil with lengths.ts?

@dpvc
Copy link
Member

dpvc commented Dec 9, 2023

If I understand correctly, you want to be able to make changes to ParseUtil functionality from the configuration options.

In the sense that it can be altered via the startup.ready() function, yes. The idea being that if someone needs to patch one of the routines, they can do so and the modified one will be used everywhere.

I have wanted to be able to do this with other namespaces (like the startup namespace in ts/components/startup.ts), but have not bee able to. That is the main reason I have to turning these into actual objects rather than namespaces.

How should be deal with this when (or if) we combine ParseUtil with lengths.ts?

I'm thinking that length.ts should also be an object as well, rather than individual functions. That would make everything mutable. Does that answer your question?

Copy link
Member

@dpvc dpvc left a comment

Choose a reason for hiding this comment

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

Looks good. I have one suggestion for saving some characters, but otherwise, ready to go.

ts/input/tex/ParseUtil.ts Outdated Show resolved Hide resolved
@zorkow zorkow merged commit 33c82c2 into develop Dec 20, 2023
@zorkow zorkow deleted the refactor/parseutil branch December 20, 2023 17:47
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.

2 participants