-
Notifications
You must be signed in to change notification settings - Fork 55
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 ability to document maps in a DRY way #389
Comments
Hi @MattDiMu, you put forward pretty good arguments here, and real usage concerns. However this might not be trivial:
Around the same topic I've been playing with a kinda literate programming style theme for SassDoc (not released), and it's not a small task. Let's see what we can do. PS: Do you have online examples of such maps ? |
MapsI agree having this kind of inline documentation for map properties would be great. My first thought was that SassDoc is not at all designed for this kind of comments. Currently, the parser (CDocParser, extended by ScssCommentParser) searches for block comments, and associate them with a context-less item below (function, mixin, variable, placeholder). Context-less because the type and name can be determined on the declaration line, there's no need to maintain some kind of context to identify it. Inline comments in maps are not compatible with this. However, there's another way to reason about this; SassDoc is able to autofill some annotations by looking at the code of a documented item. So this problem could be "just" about autofilling the So, technically a feature like this could fit in SassDoc without any modification on how SassDoc works internally (and I was not convinced it could, at first sight). The only difficulty is to write the map parser to convert these inline comments to autofilled regular VariablesThough, we cannot extend the above solution to inline documentation for variables, because we can't autofill an undocumented item. But unlike map properties, variables don't require to keep track of the context, so supporting a top-level inline comment could gracefully fit in how the parser works currently. I'm not sure about the syntax, but if we want to develop this idea: $foo: 42; /// @var {Number} The answer. ... would just be a different way to express: /// @var {Number} The answer.
$foo: 42; And yes, we don't have ConclusionWhile there's a significant amount of work required to implement this (for both maps and variables), the features can be designed in such a way that we don't need to change anything about how the core works. Since @pascalduez already answered since I began writing this, I'd just like to comment a point:
Supporting inline comments for maps autofill and variables is not enforcing anything; people can still use regular annotations in block comments, but they can use inline syntax if they want, because it has several advantages over block annotations. |
@valeriangalliat Yes, that's what i meant: Inline annotations should definitely be just an an alternative way of annotating, no replacement! @pascalduez Unfortunately I do not have any online projects, where sass maps are documented with sassdoc. In my companies projects i currently do it by ignoring the sassdoc convention at maps, as the inline comments are shown in the code section and this is simply more maintainable and readable: |
Sassdoc is great. I don't like, however, the way maps are documented, because I need to duplicate both - the name of the property as well as its value.
I've read the discussion #25 about the original implementation, there were valid arguments to implement it the way it currently is and this implementation should definitely Stay. It would be great, however, if it could be enhanced with some sort of inline documentation like
Cons:
Pro:
Personally I see SASSDOC not only as generator for a fancy documentation, but also as documentation guideline, defining the documentation syntax, which makes working in a team much easier. If I need to look after a variable/mixin/function, I often use the editor-shortcut to go to the desired file instead of opening sassdoc in my browser, as it's faster and I'm sure, that I'm not the only one. So readability, making it easy to find the corresponding annotation to a variable/property, is important to me.
PS Some sort of (optional) "inline" documentation might be useful for variables as well, as it feels "clearer" to me. Something like
What do you think, any opinions?
The text was updated successfully, but these errors were encountered: