tmdoc::tmdoc

Literate programming tool using Markdown as markup languages and Tcl as programming language. Tcl code can be embedded directly in the text using single backticks or as code blocks using triple backticks. A good example is the extensive tutorial for the tmdoc::tmdoc package at https://chiselapp.com/user/dgroth/repository/tclcode/doc/tip/tmdoc/tutorial/tmd.html

Usage: Intermixed Markdown markup and Tcl code in a tmd file can converted to Markdown using the tmdoc command line application. Afterwards the Markdown document can converted to other documentation formats like HTML, PDF or Unix manual pages for instance using the pandoc command line tool.

tclsh tmdoc.tcl docu.tmd > docu.md
# afterwards Markdown can be converted to HTML or PDF for instance using pandoc
pandoc -i doc.md -s --highlight-style pygments -c dgw.css  -o docu.html

Code chunks:

Are starting after three backticks and a {tcl} indication of the programming language. Here an example:

```{tcl echo=false}
set x 1
puts $x
```

Further short Tcl code can be embedded directly within the text using single backticks:

The curent date and time is: `tcl clock format [clock seconds] -format "%Y-%m-%d %H:%M"`

Should embed the current date and time in the text.

The manual states as well support for images created from Tcl for instance using commands from gdtcl or the canvas widget. For more information have a look at the tutorial https://chiselapp.com/user/dgroth/repository/tclcode/doc/tip/tmdoc/tutorial/tmd.html and the manual pages https://chiselapp.com/user/dgroth/repository/tclcode/doc/tip/tmdoc/tmdoc.htm

You can as well embed other programming languages like R if you use the knitr tool:

So this is possible:

    Here some R code:

    ```{r}
    print("Hello R World!")
    ```

    Now same document Tcl code:

    ```{tcl}
    puts "Hello Tcl World";
    ```

If you mix R and Tcl you must first run tmdoc and afterwards knitr . My Makefile for another tutorial looks like this:

 default:
        tclkit tmdoc.tcl ../t3-tut.tmd > t3-tut.rmd
        echo "library(knitr);knitr::knit('t3-tut.rmd',output='t3-tut.md');" | R --slave
        pandoc -i t3-tut.md -s --highlight-style pygments -c ../dgw.css  -o t3-tut.html

You can not start knitr first, as it can't handle Tcl commands.

--- Changes:

  • 2020-02-19: 0.1 first release
  • 2020-02-21: 0.2 release
    • puts -nonewline fix in the output
    • outfile and tangle options
    • manual page ready
  • 2020-02-23: 0.3 release
    • fix for puts into channels

See also:

---

Discussion:

Please discuss here ...

DDG 2020-02-19: Please note, that this is a work in progress. I am open for suggestions. But tmdoc should basically have a reasonable subset of the functionality of R's Sweave https://stat.ethz.ch/R-manual/R-devel/library/utils/doc/Sweave.pdf and R markdown https://rmarkdown.rstudio.com/