Imagine this as a node package other package distributors can use to generate the same type documentation by the click of a button, provided the same commenting rules are parseable.This makes me think: Should code-comments actually be in the format of .tid files? This would make parsing enormously straight forward.All we needed was some conventions on how to populate which (standard) fields, tags, text-templates with content. Perhaps some helper macros to cross-reference.
/**
* My method description. Like other pieces of your comment blocks,
* this can span multiple lines.
*
* @method methodName
* @param {String} foo Argument 1
* @param {Object} config A config object
* @param {String} config.name The name on the config object
* @param {Function} config.callback A callback function on the config object
* @param {Boolean} [extra=false] Do extra, optional work
* @return {Boolean} Returns true on success
*/If we used some sort of "code fencing" in the comments, we could easily discriminate between comments that had documentation in them and ones that didn't (i.e., we don't want to pick up every block comment, because some may be, well, comments! :).
/*doc
tags: util
documenting the below function
*/
/*doc
title: <should be automatic via rules, perhaps with an option to declare and thus overrule>
tags: <depending on well defined tagging rules>
namespace: $tw.utils <should be set on a file basis instead>
function: getAttributeValueFromParseTreeNode <should be automatic!>
arguments: node, name, defaultValue <should be automatic!>
node: (type of node) description of node
name: (type of name) description of name
value: (type of defaultValue) description of defaultValue
return: (type of return value) description of return value
summary: a short summary of what this function does
additional information, if there needs to be any, e.g. cross-references with other functions
! Example
a common example of how to use this function, if useful
*/
But maybe we simply use a set of prefixed field names, e.g., docs, dox, or twd, or something
I think we need to make sure we support Markdown as well as tiddlytext to start because if we want others (outside the TW community) to use it to produce documentation TWs per your suggestion, I think MD would need to be supported simply because it is more ubiquitous for that purpose, thanks to Github, etc.
Why? We know what fields we use in the docs, no prefix needed. We can't use @ as that is invalid in html attributes... an I don't see why we should.
That is possibly true, but then I would have a global setting for the repo to define what format to use, which you could overwrite for a single tiddler by setting the type field accordingly.
I see that as simply a marker that would be stripped by the parser.
I mean, we're not going to leave the trailing colons in the names either, true? :)
To me, it is a way for a parser to quickly rip through a file looking for just the strings it cares about, and something like /@([a-z]+):/i (I haven't tested that regex :) ),
//doc _namespace=$tw.utilsI can see where modules would need some "documentation" fields as well as normal "TiddlyWiki" fields, and was trying to namespace the documentation fields basically, so that we could have a something like:
/*doc
_summary: a short summary of what this function does
_namespace: $tw.utils <should be set on a file basis instead of per doc-tid>
_function: <should be automatically parsed from the function head!>
_arguments: node, name, defaultValue <should be automatically parsed from the function head!>
_node: (type of node) description of node
_name: (type of name) description of name
_value: (type of defaultValue) description of defaultValue
_return: (type of return value) description of return value
title: <should be automatic via rules, perhaps with an option to declare and thus overrule>
tags: <depending on well defined tagging rules>
type: text/markdown
additional information, if there needs to be any, e.g. cross-references with other functions
## Example
A common example of how to use this function, if useful.
*//*doc
_summary: this function does yada
_node: (node) the [[node]] bla
_name: (string) blip name blup
_value: (number) the bleep value
_return: (boolean) true: foo / false: bar
tags: utils
*/What trailing colons do you mean?
title: FooMy point was simply that prefixing it with 1-n characters to create a doc field namespace doesn't have to imply it has to be valid in HTML attributes or wherever, because they can just be stripped out by the parser.
^ - that one.
To me, with a doc-tid, we're looking at a plain tiddler definition, no special parsing,
True, with my first proposal above, if we had an argument called title or type we had a bit of a problem: We sure can't set a title or type field without breaking TiddlyWiki's representation. The simplest workaround would indeed be to prefix all fields. How about underscore, e.g. _type?
So, to putting it all together once more...
/*doc
_summary: a short summary of what this function does
_namespace: $tw.utils <should be set on a file basis instead of per doc-tid>
_function: <should be automatically parsed from the function head!>
_arguments: node, name, defaultValue <should be automatically parsed from the function head!>
_node: (type of node) description of node
_name: (type of name) description of name
_value: (type of defaultValue) description of defaultValue
_return: (type of return value) description of return value
title: <should be automatic via rules, perhaps with an option to declare and thus overrule>
tags: <depending on well defined tagging rules>
type: text/markdown
additional information, if there needs to be any, e.g. cross-references with other functions
## Example
A common example of how to use this function, if useful.
*/
My point was simply that prefixing it with 1-n characters to create a doc field namespace doesn't have to imply it has to be valid in HTML attributes or wherever, because they can just be stripped out by the parser.
that means we're going to have to deal with this:
/*doc
_summary: blah
*/
...as well as this:
/*doc
* _summary: blah
*/
...as well as this:
/*doc
** _summary: blah
*/
...unless we prohibit all but the first format.
Honestly, my original thoughts on this was to stay somewhat close to YUI/Javadoc "standards" (conventions), because those are known to a wider audience and I was hoping to get some tool reuse.
I just wonder how much wheel reinvention we'll have to do, especially if we begin parsing the function/property name and parameters directly instead of having them explicitly defined in the doc fields?
Which, again, I don't think is wrong, but increases the complexity of the solution. "The perfect is the enemy of the good" and all that.
Question: How do you see module/"class"-level documentation working? Right now we have this:
/*\
title: $:/boot/boot.js
type: application/javascript
The main boot kernel for TiddlyWiki. This single file creates a barebones TW environment that is just sufficient to bootstrap the modules containing the main logic of the application.
On the server this file is executed directly to boot TiddlyWiki. In the browser, this file is packed into a single HTML file.
\*/
/*doc-module
_namespace: bla.blup
_summary: this file defines the foo class
details, details details...
*/
Is that enough? Just extract that text, stick it under a "boot.js" header/tiddler and be done?
Another thought. If we're going to parse out the functions/properties, it would be an interesting exercise (I think) to have an automatically generated "references/referenced by" set of links, too. But that increases the complexity even more! :)
I am thinking this is actually an area where we definitely should "eat our own dogfood".
--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/d/optout.
When it comes to API docs, we should stick to standards like JSDOC. Code needs to be documented in a most comprehensible and standard compliant way to ensure other developers can pick it up and understand it fast when acutually reading the code.
/**
* @param foo {string} does bar
* @return {strong} gives blip
*
* bing bong
*/
Also, I am against reinventing the wheel it just binds way too many developer resources. Implementing a comment parser with all features is a huge project. This is valuable time we (especially Jeremy) could use to make tw better. I use JSDOC to document the plugin api (http://bit.ly/tiddlymap_api) and I can only recommend it.
It's from August 2012. You can download the ZIP file and view the index.html here:
https://github.com/Jermolene/old.jermolene.github.com/tree/e7bbdc735963b7d9dc84798eec176193ad54831d
//I stay in the build, maybe...I mean, we can sure implement jsdoc, but I believe it will significantly slow down the process and make things more complicated for the TiddlyWiki project... and only maybe easier for everyone else.
On the other hand, if you want to become familiar with TiddlyWiki's code, maybe grab some basics about how simple it is first, e.g. the tid format, and then perhaps forget jsdoc ...when given a chance to, after all.
To me, the focus is not so much to provide a jsdoc compliant TiddlyWiki doc process... but rather for us to get that API documented and have easy means to give it some smarts... WITHIN that API TiddlyWiki ...not whichever output some YUIDOC or jsdoc node implementation generates.
So, the barrier for jsdoc to bea good candidate for this project to me truly is this: Who is willing to write the parser for it? ...and willing to listen to all the complaints about "Why do I need to put all those ridiculous asterisks? They just clutter my TiddlyWiki / Markdown format." Why do I need @ param when it's all clear "_foo" is a param?
Sure, using jsdoc it would possibly be easier for someone else to output the TiddlyWiki documentation in a different way. But then I feel like I want to ask: Why? TiddlyWiki is a near perfect environment to document / expose its own API.
--Best wishes, Tobias.
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywikidev/VE4eVzoaReQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywikide...@googlegroups.com.
I think what you're missing is the jsdoc parser (and node integration) is already written, and in fact has been long written, and stable.
I think what you're missing is the jsdoc parser (and node integration) is already written, and in fact has been long written, and stable.
Ok, so what does it return? Is that usable for us? We still want to turn it into tiddlers, at least I sure do. I don't want some pdf or HTML of which YUIDOC thinks its perfect. I believe, we also want that function head parsed, not just the comments. Does it do all that in a way that we can, say, handle some big JSON output and generate the tiddlers from it?
Best wishes, Tobias.
I find it difficult to agree. Perhaps that is owed to my not being a hardcore developer but I would think that there factually is no such hardcore documentation standard. There are project guidelines, styles and implementations ...adopting this or that method, maybe jsdoc.
In some distant past, some text editor developer thought it pretty to generate.../**
* @param foo {string} does bar
* @return {strong} gives blip
*
* bing bong
*/
..I don't agree at all that we need or want to see or write those superfluous asterisks.
To me, it's quite important that we input the documentation in precisely the way we know it will render as a tiddler. This seems rather important so as to make things right. Doing the mental yoga to anticipate what some parser will do with it seems a rather poor design choice, imho. Let's stick to .tid format!
Keeping it simple and smart.
That's what I'm saying, let's not waste time on writing a jsdoc parser to crank a lot of wheels so as to turn that into tiddlers! Let's use tiddler format, because we sure know how to parse that and we know how those things end up in TiddlyWiki! Simple, straight forward.
It DOES do all the function header and parameter parsing. It gives a series of HTML pages that are all nicely cross-linked, decently styled and perfect for the (already static) dev doc site.
Frankly I am with Felix on this one. You think it won't be that much effort to add it to TW, and maybe with what Jeremy was pointing at, that's true.
But I was looking at the project as "Let's get this stuff documented to help people (like me) bleeding through trying to understand how all the code fits together NOW," and not another feature to add to TW (isn't there a moratorium? :)
To me, the thing worth investing time in was actually adding the documentation comments to the code (which doesn't affect the code in ways that needs extensive testing) to then get the documentation generated and PUBLISHED quickly.
I could get behind volunteering to write some of that documentation (because doing so would help me solidify my understanding of the codebase as a whole).
I wasn't looking for yet another coding project, which the TW approach would entail, so am not that interested in volunteering for that. Finite amount of time, different priorities and all that.
The TW approach may be more "TW-pure," and more power to whoever implements it.
Do you mean the dictionary format?
How can I document nested objects with that or go multiline?
title:foo
bar:baz
text
/**
title:foo
bar:baz
text
*//**
* title:foo
* bar:baz
*
* text
* */Do you want to write a parser that automatically does all the rendering and automatic linking?
Why do you want to do this with tiddlywiki?
This is just code documentation directed at developers. Joomla and Drupal are Content Management systems. Do they say: "let's develop and write our code docs in a joomla parsable format and publish it as a Joomla or Drupal Website?"
Do you mean the dictionary format?How can I document nested objects with that or go multiline?
I mean a simple...title:foo
bar:baz
text
...all neatly enclosed for "doc'ing".../**
title:foo
bar:baz
text
*/
If an editor needs superfluous asterisks to highlight comment blocks, then maybe it's a poor editor.
/**
* title:foo
* bar:baz
*
* text
* */Do you see how much that impinges on readability? ... if we wanted it to be tid-style?To me it's shooting our own foot, with little peas maybe. ^^
Do you want to write a parser that automatically does all the rendering and automatic linking?The parser wouldn't do that. That's the entire point. the parser would only output straight forward tiddlers. So, the miniml logic that is actually required goes into components for a TiddlyWiki API edition that does all the cross-referencing with TiddlyWiki elements, e.g. macros viewtemplate sections, etc. That's very straight forward stuff... and a pretty good case for leveraging and showcasing the power of this thing we all like.
Why do you want to do this with tiddlywiki?
Because, that's the entire point of TiddlyWiki... to be used for documentation... in this case, it's very own API.
This is just code documentation directed at developers. Joomla and Drupal are Content Management systems. Do they say: "let's develop and write our code docs in a joomla parsable format and publish it as a Joomla or Drupal Website?"
The difference is, those are not designed for that task TiddlyWiki is. All it takes is a rather simple build script (within TiddlyWIki), one that isn't all too different from the one that creates TiddlyWiki itself... and we're set.
I encourage you to take a look at that draft on GitHub, maybe that gives a more concrete image.Best wishes, Tobias.
--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/d/optout.
For interactive use, you'd just install the JS parser and view the raw tiddler modules to see the formatted documentation inline with the code.
That appears to quite constrain documentation abilities as there is no way to address and manage individual functions other than render them somewhat distinct from the surrounding code.
Best wishes, Tobias.
Do you mean that you want to browse the code by function/method rather than by file/tiddler?