Move bulk of title formatting logic to separate library#242
Conversation
- Bump maze-utils to commit 02978e0, which contains the moved title formatter logic - Uninstall cld3-asm, as all code using it is now in maze-utils - Change imports throughout - Delete title formatter tests. These now live in maze-utils
|
At the moment maze utils is not imported as a module, but a folder, so I'm not sure it would work to delete the cld-3 dependency. I think it won't compile |
|
Your understanding of submodules is correct |
Hmm, it was working on my machine. I guess I'll add that dependency back then. |
I'm now looking for a way to make the dependency optional. I was thinking putting it in peer dependencies of maze-utils and wrapping the import in a try...catch so SponsorBlock could compile without it, but...
So I'll now look into moving all of the title formatting stuff into its own library. |
|
Created a repo: https://github.com/ajayyy/DeArrowFormatting |
…ing functionality from there
Fixes Jest tests failing because there was no `test/` folder.
|
Hello. Any hopes of this getting looked at anytime soon? 😄 |
| const text = "text" in props ? props.text : chrome.i18n.getMessage(props.langKey); | ||
|
|
||
| setLabel(await formatTitleInternal(text, false, props.titleFormatting!, false)); | ||
| setLabel(await formatTitle(text, false, props.titleFormatting!, false, Config.config!.onlyTitleCaseInEnglish)); |
There was a problem hiding this comment.
What's the reason for this change?
There was a problem hiding this comment.
There are two changes here:
- Replace
formatTitleInternal→formatTitle: note thatformatTitlecomes from DeArrowFormatting, not fromtitles/titleFormatter.ts. I just movedformatTitleInternalin DeArrowFormatting, and renamed it toformatTitle.- As to why I changed the name: I thought it didn't make sense to label the function "internal" when, from the PoV of DeArrowFormatting, it was the function being exposed to the outside.
From the PoV of DeArrow, the function is used internally (which is part of the reason why I aliased it toformatTitleInternalinsrc/titles/titleFormatter.ts)
- As to why I changed the name: I thought it didn't make sense to label the function "internal" when, from the PoV of DeArrowFormatting, it was the function being exposed to the outside.
- Added
Config.config!.onlyTitleCaseInEnglishparameter: DeArrowFormatting doesn't know about DeArrow'sConfigobject anymore, so we have to pass it manually.
Bump maze-utils to commit 02978e01, which contains the moved title formatter logic
Uninstall
cld3-asm, as all code using it is now in maze-utilsChange imports throughout to use types and methods from maze-utils
Delete title formatter tests. These now live in maze-utils
I agree to license my contribution under GPL-3.0 and agree to allow distribution on app stores as outlined in LICENSE-APPSTORE
To test this pull request, follow the instructions in the wiki.
Second half of #241.
Footnotes
I'm not 100% sure how cross-gitmodule changes should work. In theory, if the maze-utils submodule is pinned to a specific commit then this should be fine, right? ↩