Folks,
Since this thread is becoming somewhat a document on using comments in tiddlywiki, I want to share a method I discovered since covid-19 (unrelated).
Consider the following facts
- After defining a set of macros in a tiddler tagged $:/tags/Macro the text below is not included in those macros
- Although comments themselves are not visible they existing in the text field and are searchable.
So lets say you define a set of macros as follows;
\define macro1(p1 p2) blahblah
\define macro2(tiddlername)
blahblah $tiddlername$
\end
<!-- syntax
Macro: macro1 `<<macro1 p1 p2>>` used to react to p1 and p2
Macro: macro2 `<<macro2 [tiddleranme]>>` tiddlername optional defaules to currentTiddler
-->
Notice documenting their syntax in the comments below?
Then a simple list can extract lines beginning Macros:
<$list filter="[all[]tag[$:/tags/Macro]]" variable=macro-tiddler>
<$list filter="[<macro-tiddler>get[text]splitregexp[\n]prefix[Macro:]]" variable=line>
<<line>> in <$link to=<<macro-tiddler>>/> <br>
</$list>
</$list>
Notice how the result ends up being rendered?
I plan to use this method through out as my own de facto standard, however I wonder if we should develop a de jure standard for this form of self documentation?
This following tiddler tagged $:/tags/ViewTemplate
<$list filter="[all[current]tag[$:/tags/Macro]]" variable=macro-tiddler>
<$list filter="[<macro-tiddler>get[text]splitregexp[\n]prefix[Macro:]]" variable=line>
<<line>> in <$link to=<<macro-tiddler>>/> <br>
</$list>
</$list>
Will display any such macro definitions in the current tiddler
The above solutions could be improved further by removing the comment block first, say one beginning `<!-- syntax`
I am however also developing a method to extract and document tiddler lines containing "\define macroname(params)"
Regards
TW Tones