-
Notifications
You must be signed in to change notification settings - Fork 19
Fix linting errors "Expected h2#Examples for data.examples" #411
Comments
For the category "Single page describing multiple features", I need some advise on what to do. These are operator pages describing multiple operators on a single page and thus they don't naturally follow our recipe. For "Examples entirely missing", I will see how it goes this week, but a helping hand would be appreciated in order to reach the sprint goal. |
@chrisdavidmills this is the issue about the remaining example section fixes that is needed in the JS docs. The linter complains about WebAssembly Module and Instance pages. These have no "Examples" sections at all. If you have an idea of what to add there, that would be great! |
This is great work Florian! About "single page describing multiple features". Let's look at each one. Arithmetic operatorsThis clearly describes multiple language features. Its structure is like:
I could think of three options here:
Assignment operatorsThis also describes multiple items although the structure is a bit different:
It's particularly weird because it has two sets of "Syntax" sections, one at the top level and one that's a series of H4's under H2#Description. I think the same options apply to this page as to "Arithmetic operators". If we were to go with option 3 it seems we could have something like:
Comparison operatorsThese have a somewhat similar structure to "Assignment operators":
It's a little different because the page has a top-level separation between equality operators and relational operators. If we want to go with option 3 above we could do something like:
Destructuring assignmentThe one is quite different:
To me the last two sections above, "H2 Array destructuring" and "H2 Object destructuring" contain examples. So I'd just move them into a new H2#Examples section. One question is whether to keep those "Array destructuring" and "Object destructuring" sections:
...or to flatten the examples:
I think flattening them would be preferable, since we kind of want items under H2#Examples to be individual examples (although we don't lint for this). But I think not flattening would be OK in this situation too. Logical operatorshttps://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators This page covers three operators (
The three that I've marked look like examples, the rest look fine in H2#Description. So we could do:
Note that there's no H2#Syntax in this page. We could extract that out of H2#Description though. Object initializerhttps://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer This doesn't seem to cover multiple operators? But it has a structure like:
It looks like this is just missing an H2#Examples section. (It's interesting to note that (and this applies to some of the other pages too) the style of documentation here is very example-driven. Our page structure separates "description" and "examples" at the top level, which moves examples further away from descriptive prose, and this is a drawback. On the other hand, having examples corralled under an H2 makes it easier for people to find an example of the thing they are looking for.) |
Thanks for adding these Chris! For future reference: the linter expects examples under H2#Examples to live under an H3 describing each example, even if there's only one of them: https://github.com/mdn/stumptown-content/blob/master/project-docs/linter-spec.md#dataexamples. I have added H3s here, and the linter is now happy with the WebAssembly docs. But you might like to check the H3s I have added. |
Cheers for the explanation Will. I've tweaked them a little bit. I've also added another I'll get on with some more JS examples tomorrow. |
Oh yes, I forgot to ask about this. I only added this catch-all example demonstration recently when the linter complained to me. I like it, but of course we could also say that namespaces need no example sections. |
OK. I opened #464 to consider it. I'm not sure if we should, but there's a good place to take that conversation, at least. Also, I added examples for these two:
If someone else wants to take a quick look at them, I'd appreciate it. Given the suggestion that you'll probably never call the methods directly, the examples seem a bit contrived. Plus, I didn't really know anything about Symbols before today. 🤷♂️ |
@ddbeck I'd say these symbol examples look OK. Compared to regular JS, accessing them is a little strange, and you'd rarely have much cause to use them in a real app. So I think a light example of how to access those values is fine for now. I did a whole bunch of these on Friday, as you can see from the checkboxes. I'm gonna do some more today too. |
I just did an example for but then I tried doing an example for https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search#Examples — after racking my brains for a while, I just ended up copying the interactive example. It really is quite hard to think up anything useful for each Symbols. But then, it probably isn't a very good idea to repeat the Interactive Example. Any thoughts on what might be better here? |
So, I think Symbols are used to implement custom behavior for some built-in methods or operators. In this case it is to customize string search. So, I've modified the example to show how to implement a case insensitive search. Not sure if useful, but it demonstrates the mechanics some more, I think? |
Thanks Florian! This certainly makes it clearer to me how they could be used. I'll have a go at doing another one in a similar fashion (i.e. copying the interactive example, and extending it a bit). |
|
I've done the page split for https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators. It now redirects to https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators The separate pages I've created are here: BCD: mdn/browser-compat-data#6235 So, here the split involved 3 operators and took me a little less than 2 hours. Also updated https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Logical to link to the new pages. |
I'm working on the comparison operators now. I've written up pages for the equality operators: No BCD or interactive examples yet. I'd love some review, because I've written quite a bit of new content here and it is tricky! Note that this is intended to replace most of the content currently in https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators. But if I have mangled anything there or omitted important stuff, that would be good to know. |
I think this looks great, Will! I like the example sections a lot. I helps me to differentiate these a lot better. Nice work! It would probably be good to (prominently) link to https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Comparison from these pages for those who want to compare the comparison operators (ha!) all at once. |
I've written up pages for the other four comparison operators: https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Greater_than ...and filed a PR for the BCD. |
For arithmetic operators, I've redirected https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators to https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators and updated the links on https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators. I've also updated https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators. The BCD will ship this week, but I marked the task for arithmetic operators as complete already here. Thanks for your help with this, Will! I really like the new pages. |
Comparison operators now all have their own pages with interactive examples, and BCD is merged. Thanks for the reviews! I've also made https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators into a redirect and updated the links from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators. I'm marking this one as complete as well. |
Assignment operators now have their own pages with BCD merged. Half of the interactive examples are in place, missing is only the second part for the bitwise assignment operators: mdn/interactive-examples#1605 <-- this is now done as well. Marking assignment operators as complete. |
For bitwise operators, the BCD is done and included in todays package. Two things came up that I'd like feedback on. This is on the current bitwise operator page:
|
I decided to remove the sections I mentioned above. This work is now complete. The linter returns 0 errors. |
We need to update the JS docs to have example sections. This affects quite some pages:
20 errors javascript-method/data.examples/expected-heading
17 errors javascript-constructor/data.examples/expected-heading
15 errors javascript-language-feature/data.examples/expected-heading
9 errors javascript-class/data.examples/expected-heading
8 errors javascript-property/data.examples/expected-heading
6 errors javascript-namespace/data.examples/expected-heading
= 75
The text was updated successfully, but these errors were encountered: