-
Notifications
You must be signed in to change notification settings - Fork 401
CLDR-17599 Path descriptions: enable macro substitution #5055
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
base: main
Are you sure you want to change the base?
Conversation
-In PathDescriptions.md and PathDescriptionHints.md, use shorter forms of paths, omit ldml, no anchors; use variable anyAttribute instead of raw regex -Store variables in the .md files; new VARIABLES section, new methods inVariables, addVariable -In PathDescriptionParser, call lookup.add instead of lookup.addWithoutVariables -Use lazy initialization for pathHandling and pathHintsHandling, to facilitate debugging -Revise TestPathHeader.Test8414 to check for brackets instead of http, since URLs moved to bottom of file -Revise PathDescriptionParser.parse to take file name instead of big string as parameter, so error message has the correct file name -Make parts of PathDescription.java private if they do not need to be public
## HINT descriptions | ||
|
||
### HINT | ||
|
||
- `^//ldml/units/unitLength\[@type="(long|narrow|short)"\]/unit\[@type="duration-day"\]/(displayName|unitPattern\[@count="one"\]|unitPattern\[@count="other"\])$` | ||
- `units/unitLength\[@type="%unitLengths"\]/unit\[@type="duration-day"\](/displayName|/unitPattern\[@count="%anyAttribute"\])` |
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.
Don't you need to add all variables before they are encountered?
## HINT descriptions | ||
|
||
### HINT | ||
|
||
- `^//ldml/units/unitLength\[@type="(long|narrow|short)"\]/unit\[@type="duration-day"\]/(displayName|unitPattern\[@count="one"\]|unitPattern\[@count="other"\])$` | ||
- `units/unitLength\[@type="%unitLengths"\]/unit\[@type="duration-day"\](/displayName|/unitPattern\[@count="%anyAttribute"\])` |
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.
Using the short forms, you should be removing the '' in front of each [
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.
I'm guessing you mean removing the backslash \
(which github hides unless escaped).
I tried removing backslash in front of both left and right brackets, and exceptions get thrown from exampleGenerator.getHelpHtml
. The first such error occurs for
units/unitLength[@type="%anyAttribute"]/unit[@type="duration-day"]/displayName
In order to use the "short forms" do I need to create the RegexLookup
differently? Currently it's
private final RegexLookup<Pair<String, String>> lookup =
new RegexLookup<>(RegexLookup.LookupType.OPTIMIZED_DIRECTORY_PATTERN_LOOKUP);
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.
Here's one error:
Caused by: java.util.regex.PatternSyntaxException: Illegal character range near index 61
units/unitLength[@type="%anyAttribute"]/unit[@type="duration-day"]/displayName
^
at java.base/java.util.regex.Pattern.error(Pattern.java:2028)
It thinks the hyphen in "duration-day" is part of a regex
Why is
Actually, only redundant |
LGTM otherwise but questions |
When building a regex lookup, you have the option of supplying simpler paths. It just handles some of the quoting so that you don't have to explicitly escape the leading sq brackets for an attribute, and adds a prefix. Done at RL build time so no apprec. Perf cost |
PathHeader.java shows the right incantation (and PathHeader.txt shows it in action).
I was wrong about the prefix. It just adds ^ to //, so you'd still need the //ldml/ Hope that helps. |
That involves I suspect |
-In PathDescriptions.md and PathDescriptionHints.md, use shorter forms of paths, omit ldml, no anchors; use variable anyAttribute instead of raw regex
-Store variables in the .md files; new VARIABLES section, new methods inVariables, addVariable
-In PathDescriptionParser, call lookup.add instead of lookup.addWithoutVariables
-Use lazy initialization for pathHandling and pathHintsHandling, to facilitate debugging
-Revise TestPathHeader.Test8414 to check for brackets instead of http, since URLs moved to bottom of file
-Revise PathDescriptionParser.parse to take file name instead of big string as parameter, so error message has the correct file name
-Make parts of PathDescription.java private if they do not need to be public
CLDR-17599
ALLOW_MANY_COMMITS=true