Case sensitive macro names? #448
Replies: 8 comments 44 replies
-
I prefer lowercase for xref macros ( FYI, here's the macro count on main (for the JS section): And here's the set of macro casings I settled on tentatively: |
Beta Was this translation helpful? Give feedback.
-
I would be very happy if (a) all macros can use snake_case (b) they are all valid JS identifiers, but that sounds far too disruptive. |
Beta Was this translation helpful? Give feedback.
-
I would love to see
I did try to make macro calls consistent before, tried changing to camel case. But changing massive amount of files just to change case was not welcomed.
Using our custom linter will be more effective than the Yari flaws mechanism. As we are on the topic of prettying the macro calls, we need to iron out following issues as well:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for kicking off the discussion, it's frustrating to grep through for matches as we have so many different formats. No preference on the casing, but it would be great to stick to one format per macro. The same sentiment on the list Onkar has pointed out; it would be great to be inflexible on these cases. No preference:
Preference:
|
Beta Was this translation helpful? Give feedback.
-
For naming, I prefer snake case to camel case, but I don't really care as long as we don't have more than one naming convention. I don't want to have to remember which convention to use for which macro, that's just ridiculous. If we're going to do that we might as well leave things in the current mess and save a lot of grief.
Yeah, I agree, this is best, and next best, if we don't want to rename, would be just to adopt snake case.
For renaming: the disruptiveness I think is mostly in two parts:
For the first of these, I think the additional disruption on top of just snake-casing is not that great, just because most of our invocations use at least one uppercase letter. I made a spreadsheet: https://docs.google.com/spreadsheets/d/1oXrwRhLRM745z0QOAm53ezaPcI55SId9gsFV4ffA7gQ/edit?usp=sharing that lists all the different macro invocations in all our docs, and tries to assess for each one:
You can see most of the diffs - 71370 - are incurred in snake-casing, and only an additional 3105 in renaming. (This also shows that just snake-casing is a BIG change, and hard for humans to review reliably. IMO we should use machines to test the change instead of relying on human review.) One open question there is whether we rename xrefs (e.g. domxref to dom_xref) - @Josh-Cena above proposed we make an exception for xrefs. For these numbers I excluded xrefs, but that would add a lot more churn. The second part of disruptiveness - getting people used to using new names - is harder to quantify, but I think it would be OK. We will get used to the names quickly enough. But renaming also tends to open another worm-can. Why are some of our xrefs called |
Beta Was this translation helpful? Give feedback.
-
Regarding other macro related suff.
-- {{Macro('arg')}}
++ {{Macro("arg")}}
-- {{EmbedLiveSample("audio", 250, 250)}}
++ {{EmbedLiveSample("audio", "250", "250")}}
-- {{CSSref()}}
++ {{CSSref}}
-- {{ APIRef }} {{ Non-standard_header }} {{ deprecated_header }}
++ {{APIRef}} {{Non-standard_header}} {{deprecated_header}}
-- {{EmbedLiveSample("audio", "100", "70")}}
++ {{EmbedLiveSample("audio", "100%", "70px")}} No preference for following cases: -- {{EmbedLiveSample('audio', '', '70px')}}
++ {{EmbedLiveSample('audio', '100%', '70px')}}
-- {{EmbedLiveSample("Audio example")}}
++ {{EmbedLiveSample("audio_example")}} |
Beta Was this translation helpful? Give feedback.
-
Using command line we can use following shell script: # 1. get fresh `mdn/content` code
# 2. assuming you've the latest yari code and done `yarn install`
cd /projects/mdn/yari
yarn build --locale en-us
mv client/build /temp_dir/build
# 3. do the macro renaming in `mdn/content`
# 4. build content again
yarn build --locale en-us
# 5. list the files that are different
diff -qr /temp_dir/build/ client/build > different_files.log On Windows I think this should run without any issues in GIT BASH. |
Beta Was this translation helpful? Give feedback.
-
So in the sheet there were are few contentions around the xref and suffixes
|
Beta Was this translation helpful? Give feedback.
-
Yari is case insensitive with respect to macro names - so in the docs we have
{{glossary("Xxxxx")}}
,{{Glossary("Xxxxx")}}
, and {{Deprecated_Header}} and {{deprecated_header}}, and so on.Josh has started looking at consistency for the naming in JavaScript section: mdn/content#29008 and mdn/content#29006. The selected format is the most common used, which probably matches https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Page_structures/Macros/Commonly_used_macros.
Consistency makes me happy, but since the macros are MDN-wide I think it is worth making sure we are all happy with both making this change, and the actual agreed format.
My preference is:
Beta Was this translation helpful? Give feedback.
All reactions