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

Improve Hyde title generation helper #120

Conversation

caendesilva
Copy link
Member

The Hyde::titleFromSlug() helper is internally moved and is referenced through the new Hyde::makeTitle() helper which is an improved version, with a more general name. This is done by replacing the underlying implementation to use the Str::headline() helper instead of Str::title(), combined with a lookup table of auxiliary words that should be lowercase, while ensuring the first word is always capitalized.

The helper does not support fully uppercase input, which is okay since it is mainly intended to convert slugs to titles, as a fallback. I think it may be out of scope to parse uppercase input Hyde source filenames are recommended to be lowercase, but am open to change if requested.

@caendesilva caendesilva changed the title 117 style bug hyde title parser should not capitalize non principal words Improve Hyde title generation helper Jul 1, 2022
@codecov
Copy link

codecov bot commented Jul 1, 2022

Codecov Report

Merging #120 (b161920) into master (350db6d) will decrease coverage by 0.10%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master     #120      +/-   ##
============================================
- Coverage     99.12%   99.02%   -0.11%     
- Complexity      749      750       +1     
============================================
  Files            97       97              
  Lines          1952     1956       +4     
============================================
+ Hits           1935     1937       +2     
- Misses           17       19       +2     
Impacted Files Coverage Δ
packages/framework/src/Hyde.php 80.00% <ø> (-20.00%) ⬇️
.../framework/src/Actions/GeneratesNavigationMenu.php 100.00% <100.00%> (ø)
...ackages/framework/src/Concerns/HasDynamicTitle.php 100.00% <100.00%> (ø)
...ackages/framework/src/Helpers/HydeHelperFacade.php 100.00% <100.00%> (ø)
.../framework/src/Models/DocumentationSidebarItem.php 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 350db6d...b161920. Read the comment docs.

@caendesilva caendesilva merged commit 7e77498 into master Jul 1, 2022
@caendesilva caendesilva deleted the 117-style-bug-hyde-title-parser-should-not-capitalize-non-principal-words branch July 1, 2022 11:05
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.

Style bug: Hyde title parser should not capitalize non-principal words
1 participant