-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
Move bulk of title formatting logic to separate library #242
base: master
Are you sure you want to change the base?
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? 😄 |
@@ -19,7 +19,7 @@ export const FormattedText = (props: FormattedTextProps) => { | |||
(async () => { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two changes here:
- Replace
formatTitleInternal
→formatTitle
: note thatformatTitle
comes from DeArrowFormatting, not fromtitles/titleFormatter.ts
. I just movedformatTitleInternal
in 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 toformatTitleInternal
insrc/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!.onlyTitleCaseInEnglish
parameter: DeArrowFormatting doesn't know about DeArrow'sConfig
object 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? ↩