-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
fakedata: add page #5675
fakedata: add page #5675
Conversation
The build for this PR failed with the following error(s):
Please fix the error(s) and push again. |
Co-authored-by: bl-ue <54780737+bl-ue@users.noreply.github.com>
Error seems outdated. 😇 |
Co-authored-by: bl-ue <54780737+bl-ue@users.noreply.github.com>
Thank you @bl-ue for the typos and the reword suggestions. 😎 |
Co-authored-by: bl-ue <54780737+bl-ue@users.noreply.github.com>
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, however it really confused me that data is the plural of datum and I fear it may confuse others too.
Let's see what others have to say about that then. @sbrl |
pages/common/fakedata.md
Outdated
|
||
- Generate data using a custom output template (capitalize the first letter of generators): | ||
|
||
`echo "value: {{Generator}}" | fakedata` |
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.
`echo "value: {{Generator}}" | fakedata` | |
`echo "value: {{generator}}" | fakedata` |
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 used "Pascal case" on purpose because:
If the generator name is a single word, then it's available as a function with the same name capitalized (example: int becomes Int). If the generator name is composed by multiple words joined by dots, then the function name is again capitalized by the first letter of the word and joined together (example: product.name becomes Product.Name).
See https://github.com/lucapette/fakedata#generators-1
What do you think of this "intentional violation"? 😇
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.
🤔 all the custom format is the custom argument option in this example, so the valid highlight is the following:
`echo "value: {{Generator}}" | fakedata` | |
`echo "{{value: Generator}}" | fakedata` |
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 prefer the original capitalized Generator
to generator
. It's required anyway. @navarroaxel see the example description itself; it mentions this oddity.
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.
@nicokosi maybe it would be better to change the parenthetic message to the first letter of generator names must be capitalized
, that sounds a bit clearer.
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 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.
@nicokosi I believe @navarroaxel is right about the extents of the token syntax; "value: " is your own custom text and there fore should be highlighted as needed. https://github.com/tldr-pages/tldr/pull/5675/files#r606702953
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.
Actually, I see that there's an issue here. fakedata
has a special syntax for their templates where you enclose the capitalized template name in {{
and }}
. Both the capitalization and the braces are required because fakedata
uses the Go template
library. The issue with that is that we at tldr-pages use that very syntax for a different purpose: that of highlighting user-entered values.
Instead of the original text here and @navarroaxel's suggestion, the appropriate would be this:
echo "{{value: {{Generator}}}}" | fakedata`
However, many clients do a blind replace of {{
and }}
with HTML/ANSI escape codes that highlight the text, so we might need some sort of escaping, e.g.
echo "{{value: \{\{Generator\}\}}}" | fakedata`
But I'm just not sure. @sbrl what should we do here?
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.
Actually, I see that there's an issue here.
fakedata
has a special syntax for their templates where you enclose the capitalized template name in{{
and}}
. Both the capitalization and the braces are required becausefakedata
uses the Gotemplate
library. The issue with that is that we at tldr-pages use that very syntax for a different purpose: that of highlighting user-entered values.Instead of the original text here and @navarroaxel's suggestion, the appropriate would be this:
echo "{{value: {{Generator}}}}" | fakedata`
However, many clients do a blind replace of
{{
and}}
with HTML/ANSI escape codes that highlight the text, so we might need some sort of escaping, e.g.echo "{{value: \{\{Generator\}\}}}" | fakedata`
Done in 8ce9022.
Left a comment here @bl-ue: #5675 (comment) |
This comment has been minimized.
This comment has been minimized.
Done in 1c0bcc0. |
Thank you @nicokosi. I left a new comment here: #5675 (comment) |
Co-authored-by: bl-ue <54780737+bl-ue@users.noreply.github.com>
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.
Seems OK for me. @sbrl, still any blockers on your side? |
|
||
- Generate data using a custom output template (the first letter of generator names must be capitalized): | ||
|
||
`echo "{{\{\{Generator\}\}}}" | fakedata` |
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.
Oh wow, this is a very awkward situation here. We don't actually define any standard way to escape this in the client spec. This is the only thing we mention:
Although this specification is about the interface that clients must provide, it is also worth noting that pages are written in standard CommonMark, which the exception of the non-standard
{{
and}}
syntax, which surrounds values in an example that users may edit. Clients MUST NOT break if the page format is changed within the CommonMark specification.
So the escaping with the backward slashes won't be handled correctly here. What happens if you remove the backwards slashes? How do clients handle that? I would assume that since the syntax can't be nested they would display it?
I think a client spec update is in order to properly define our non-standard token syntax.
Sorry to drag the review process out!
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.
Also @sbrl some clients just blindly replace {{
and }}
with ANSI codes/HTML to highlight, e.g. hidroh/tldroid (though that client it no longer maintained and we're going to remove it soon I think, #4044)
@navarroaxel I'm not sure this was supposed to be merged actually, see our conversation above. |
common/
,linux/
, etc.)