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
Add warning for including empty segments or files in optional mode #2506
Conversation
Hi @Tim-Siu, is this the desired behaviour? In other words,
will log a warning regardless of whether the include is optional or not. |
@Tim-Siu Also once again, please look at the checklist to see if you missed out on anything and check it off if you have done it.
|
Hi @yucheng11122017 , Currently empty includes without |
Hi @yucheng, Regarding the checklist:
Thank you once again for your comments. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2506 +/- ##
==========================================
+ Coverage 50.99% 51.03% +0.03%
==========================================
Files 124 124
Lines 5383 5387 +4
Branches 1160 1163 +3
==========================================
+ Hits 2745 2749 +4
Misses 2348 2348
Partials 290 290 ☔ View full report in Codecov by Sentry. |
Hi @Tim-Siu, I believe that the purpose of #2181 is to log when a user includes on a fragment that is empty. You can take a look at the test case added by the original PR which lead to this issue. The idea is that if there a empty fragment like <div id="empty />, there should be a log that tells the user they are including an empty fragment. Eg.
In trialInclude.md
Because the div is empty, we add a log statement for the user. Right now, you are logging only if the fragment does not exist and optional is enabled. Eg. In trial.md
In trialInclude.md there is no tag with missing id. We don't need this behaviour when optional is enabled because the whole idea is that if optional is enabled, the fragment can be skipped. Otherwise, the user shouldn't have enabled optional in the first place. Please let me know if you don't understand - Will be happy to explain again |
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.
Hi @Tim-Siu thanks for the work!
One clarification: is the intention also to add a logging statement if the included file is empty?
Eg.
In trial.md
<includes src="trialInclude.md" />
while trialInclude.md is present but the file is empty.
This behaviour doesn't trigger a warning right now.
Could you also fix the fact that the It can be similiar to the one for page nav
|
@@ -66,7 +66,7 @@ function _getBoilerplateFilePath(element: MbNode, filePath: string, config: Reco | |||
function _getSrcFlagsAndFilePaths(element: MbNode, config: Record<string, any>) { | |||
const isUrl = urlUtil.isUrl(element.attribs.src); | |||
|
|||
// We do this even if the src is not a url to get the hash, if any | |||
// We do this even if the src is not an url to get the hash, if any |
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.
'a' is actually the correct word as url is pronounced as 'you-ar-el' which leads to the first "sound" letter being 'y'. This article explains in more detail https://owl.purdue.edu/owl/general_writing/grammar/articles_a_versus_an.html
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.
Sorry for this. It was highlighted by static analysis and I thought it was a valid typo HAHA
Co-authored-by: Chan Yu Cheng <77204346+yucheng11122017@users.noreply.github.com>
Thank you for your suggestions. I have made changes accordingly. |
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.
Small nit
<div id="examples"></div> | ||
<div id="examples" class="d-none"> | ||
|
||
You can see an example of a Site Navigation Menu ==on the top== of <a target="_blank" href="{{ baseUrl }}/userGuide/formattingContents.html">this page</a>. |
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.
Er isn't it on the left?
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.
LGTM!
@KevinEyo1 Each PR must have a SEMVER impact label, please remember to label the PR properly. |
What is the purpose of this pull request?
Overview of changes:
Related to #2180
Resolve #2181
Add warning message in the case that empty files or segments are included in the
<include .... optional/>
case.Anything you'd like to highlight/discuss:
Testing instructions:
Minimal reproduction:
The log warning expected:
Proposed commit message: (wrap lines at 72 characters)
Add warning for including empty segments or files in optional mode
Checklist: ☑️
Reviewer checklist:
Indicate the SEMVER impact of the PR:
At the end of the review, please label the PR with the appropriate label:
r.Major
,r.Minor
,r.Patch
.Breaking change release note preparation (if applicable):