Ruff!

Ruff! is a documentation generation system for programs written in the Tcl programming language.

News

  • 2024-10-04 Ruff! 2.4 released. V2.4 adds Tcl 9 support and TclOO properties
  • 2022-06-05 Ruff! 2.3 released. V2.3 adds collapsible procedure descriptions
  • 2022-03-21 Ruff! 2.2 released. V2.2 adds support for embedded diagrams using ditaa, PlantUML etc.

Ruff! (Runtime function formatter) is a documentation generation system for programs written in the Tcl programming language. Ruff! uses runtime introspection in conjunction with comment analysis to generate reference manuals for Tcl programs. For more on the benefits, see Why Ruff! .

Downloads and release notes at https://sourceforge.net/projects/magicsplat/files/ruff/ .

Documentation is at https://ruff.magicsplat.com .

Source repository at https://github.com/apnadkarni/ruff .

Examples

Ruff! , cffi , CAWT , MAWT , PAWT , tcl-promise , iocp , apave , baltip , hl_tcl , tomato , obex , Woof! and tcl-vix .

Historical

(comments on older releases that shipped with Woof!)


AMG: Looks very exciting! I can't wait to see the code for this. I'll be happy to start using it in my projects.

Many years ago I had thought of writing a documentation generator, but it had not occurred to me that I could harness Tcl's vast introspection capabilities. As a result, it would have been extremely limited, doing nothing more than extracting specially-formatted comments (while ignoring the actual code) and dumping them to HTML or similar. It would have allowed me to interleave code and documentation, but it would also have required that the documentation effectively duplicate the code.

Side note: On this Wiki, be careful with words underlined with ==='s, when the words are three or six characters long. The underlines may be interpreted to start or stop a block of preformatted text!

RUntime Fact Finder?


I think that RS's docstring is noteworthy here, it's a concise demonstration of the mentioned introspection capabilities to document Tcl source. -- Effe APN Hmmm... that's only ten lines. I better go figure what the other 2490 lines of my code are doing! Effe: I don't want to criticize your work! I just wanted to point to the core concept of introspection to gather the needed information, it's a mind-sized bite to understand a tiny part of your program (and a tiny part of Tcl). I learned myself much about Tcl's capabilities by following link after link on this wiki and this is one of those links, tightly coupled to the topic. The honor of giving us a much more elaborated work that goes far beyond docstring is nevertheless due to you. APN Effe I really didn't take your reference as criticism at all! Honest! My remark was purely in jest, not intended as sarcasm. As you say, the Wiki offers a lot, and if you see any of my open source code, you'll see lots attributed to various Wiki pages in the comments.


AMG: Ruff!'s source display would be much improved if only backslash-newline-whitespace weren't replaced with space within braces. Instead I think line continuations should be handled by the evaluation loop, as when the backslash-newline-whitespace appears at the top level of a script (or is entered interactively or via eval) with no braces in sight. Alas, we are stuck with the source display showing all the wrapped lines jammed back together. This misfeature also impacts line counting throughout Tcl error messages.

See [L1 ] for more.


aplsimple - 2020-02-29 17:23:58

Perhaps, these remarks would be helpful:

  • The _ruff_preamble variable may contain tables of definitions. It would be nice to have <code></code> tags for the left column of terms, like in the comments of procedure/method - just for a consistency of view. APN No, because not all tables are assumed to be definitions. The ones within procedures are distinguished as such because of their placement at the top of the procedure.
  • Ruff! makes NS.html#link for a document's internal links. Perhaps, a simple #link would be better (shorter in any case) because if, for some reasons, you rename NS.html to NS_guide.html, those links don't work. APN Yes. Perhaps in a future release.
  • "See also:" can include only links to procedures/methods and bracketed links. Seemingly, direct WWW link and <WWW link> don't work. APN Done. Was meant only for program element references. Now changed in repository to permit Markdown links.
  • "Show source" adds a new line under a proc, which would be good if there weren't a new line in the proc by itself (two blank lines are created by Ruff! in this case) APN I think this only happens if there is in fact a blank line at the end of the original procedure. In which case, it is reflected in the Show source.
  • It would be nice to have a link to Ruff! site in the bottom message "Document generated by Ruff!". APN. Good idea. Done.
  • ...and to have some options of customizing, e.g. for colors and width ratio of TOC/description. When the generated documents are injected into an external site, it's desirable to have them a bit consistent with the site. APN There is now a -stylesheets option. Note the YUI CSS used for gridding is still included but the Ruff-specific pieces can be overridden by specifying new stylesheets. Be aware my CSS is structurally horrible if you clone the default ruff css :-)
  • ...and to emphasize sections' titles (for more readability), e.g. with <br><h2 class='ruff'> and <br><h4 class='ruffproc'>. APN May be. But I've gone through so many iterations in fonts, it is now what it is. You can use the stylesheets to change this though.
  • ... and to highlight a Tcl syntax in "Show source", at least basic - keywords and comments (strings perhaps) APN Would be nice but more work than I can manage now I'm afraid. I'll take a look at your mulster reference later when I again have some time for Ruff.

The last four proposals are seen in trimmer.html tuned for this reason by mulster utility that can be also used for fine tuning of other generated documents, e.g. made by mkdoc::mkdoc, to satisfy different tastes of users.

APN Yes, those remarks are helpful, thanks :-) Just awaiting the time I work on Ruff next.

2021-01-28 Released 1.1.0 but forgot about the above requests. APN 2021-04-20 Most marked done, remaining probably not for now.


apIsimple - 2020-09-27 03:57:05

Would it be useful if <img...> tags will be not modified by Ruff!? Now they are converted to be readable as is (with &quot; &gt; etc.) so that not working in a resulting Reference page. APN I could not reproduce this with current (2021-04-20) code. Images show up in the output using both HTML and Markdown syntax. APN Fixed in 2.0. The problem was only showing up if the tag had an attribute (like alt) with and empty string value.


RZ - 2021-02-08 14:58:28

Currently only oo::class classes and no metaclasses are recognized in proc ruff::private::extract_procs_and_classes because of line :

set class_names [info class instances ::oo::class $pattern]

May be add an option -metaclasses and do an "[info class instances $metclass ..]".

APN 2021-12-09 v2.0 includes metaclass docs automatically.

And another one. in proc ruff::private::get_ooclass_method_path

you have

    #ruff - next in the search path is the class itself
    if {lsearch -exact [info class methods $class_name -private $method_name] >= 0} {
        lappend method_path $class_name
    }

Should it not -all -private ? APN No, that line wants to explicitly ignore methods that are inherited which -all will include.


Torsten Berg - 2021-02-22 What a great package! Especially since it is quite close to my documentation manners anyway. The way Ruff! needs proceudres documented is pretty much how I do it anyway. So I can add that automatic documentation to my code with just a little bit of tweaking. And ... I get markdown on top for free!

That said, there is room for more. I just started a project where I need the documentation in German. So I added the few bits to version 1.1.0 to allow for localization using the standard Tcl package msgcat. Instead of setting the locale from an environment variable, I added a -locale option to ::ruff::document making room for maximum flexibility.

You can find my code in the Github issue I created for this: https://github.com/apnadkarni/ruff/issues/44 APN 2021-04-21 picked up that code with some minor changes as noted in the issues.

Oh, and I can't help noticing the similarity to "roff" (or troff, groff) when saying that word "Ruff!". Is that maybe intentional?? APN Never realized that! Ruff! was originally part of the Woof!/Ruff!/Bowwow! family.