102 |
103 |
104 |
--------------------------------------------------------------------------------
/mdconvert.sthlp:
--------------------------------------------------------------------------------
1 | {smcl}
2 | {it:v. 1.3}
3 |
4 |
5 | {title:mdconvert}
6 |
7 | {p 4 4 2}
8 | {bf:mdconvert} converts {browse "https://daringfireball.net/projects/markdown/":Markdown} to
9 | Microsoft Word {bf:docx} or {bf:pdf} within Stata
10 |
11 |
12 | {title:Syntax}
13 |
14 | {p 8 8 2} {bf:mdconvert} using {it:filename} [, {it:options}]
15 |
16 | {p 4 4 2}{bf:Options}
17 |
18 | {col 5}{it:option}{col 27}{it:Description}
19 | {space 4}{hline 75}
20 | {col 5}{ul:rep}lace{col 27}names of the exported file
21 | {col 5}name{col 27}bold face text
22 | {col 5}{ul:e}xport(name){col 27}document format which can be {bf:docx} or {bf:pdf}
23 | {col 5}{ul:t}itle(str){col 27}title of the document
24 | {col 5}{ul:au}thor(str){col 27}author of the document
25 | {col 5}{ul:aff}iliation(str){col 27}author affiliation
26 | {col 5}{ul:add}ress(str){col 27}author address or email
27 | {col 5}{ul:sum}mary(str){col 27}abstract or summary of the document
28 | {space 4}{hline 75}
29 |
30 | {title:Description}
31 |
32 | {p 4 4 2}
33 | {bf:mdconvert} is an alternative to {browse "https://pandoc.org/":Pandoc} for converting
34 | Markdown documents to {bf:docx} and {bf:pdf} within Stata 15. This package was
35 | developed to support {browse "https://github.com/haghish/markdoc":markdoc} package and
36 | allow generating dynamic documents independent of Pandoc or
37 | {browse "https://wkhtmltopdf.org/":wkhtmltopdf} for generating Microsoft Word and
38 | PDF documents respectively.
39 |
40 |
41 | {title:Limitations}
42 |
43 | {p 4 4 2}
44 | Generating docx and pdf files in Stata 15 is done using the {bf:putdocx} and
45 | {bf:putpdf} commands. Compared to Pandoc, these commands are still very limited
46 | and do not fully cover the Markdown syntax. For example, they do not allow:
47 |
48 | {break} 1. horizontal line
49 | {break} 2. Hyperlink
50 | {break} 3. Nested lists
51 | {break} 4. Mathematical notations
52 |
53 |
54 | {title:Examples}
55 |
56 | {p 4 4 2}
57 | convert Markdown file to docx
58 |
59 | . mdconvert using "markdown.md", name(mydoc) export(docx) replace
60 |
61 | {p 4 4 2}
62 | convert Markdown file to pdf
63 |
64 | . mdconvert using "markdown.md", name(mydoc) export(pdf) replace
65 |
66 |
67 | {title:Author}
68 |
69 | {p 4 4 2}
70 | E. F. Haghish {break}
71 | University of Göttingen {break}
72 | {it:haghish@med.uni-goesttingen.de} {break}
73 | {browse "https://github.com/haghish":https://github.com/haghish}
74 |
75 |
76 | {title:License}
77 |
78 | {p 4 4 2}
79 | MIT License
80 |
81 | {space 4}{hline}
82 |
83 | {p 4 4 2}
84 | This help file was dynamically produced by
85 | {browse "http://www.haghish.com/markdoc/":MarkDoc Literate Programming package}
86 |
87 |
88 |
--------------------------------------------------------------------------------
/Torture_test/Beamer/example.do:
--------------------------------------------------------------------------------
1 |
2 | qui log using example, replace
3 |
4 | /***
5 |
6 | ---
7 | title: "Dynamic Slides in MarkDoc Package"
8 | author: E. F. Haghish
9 | date: February 2016
10 |
11 |
12 | output:
13 | beamer_presentation:
14 | theme: "Boadilla"
15 | colortheme: "lily"
16 | fonttheme: "structurebold"
17 | ---
18 |
19 | Creating dynamic slides in Stata
20 | ================================
21 |
22 | - Dynamic slides are slides created for statistical representation and thus,
23 | includes code and output from Stata.
24 |
25 | - The __`markdoc`__ command allows you to
26 | easily create a _smcl log file_ and use it for creating dynamic analysis
27 | reports or even PDF slides. In this tutorial I will demonstrate how to quickly
28 | create the slides from Stata. Here are a few capabilities of the package.
29 |
30 |
31 | About MarkDoc
32 | =============
33 |
34 | MarkDoc is a general purpose literate programming package that can export
35 | dynamic reports in several formats within Stata. However, this tutorial only
36 | demonstrates the dynamic slide feature.
37 |
38 | - Adding images and figures
39 | - Interpreting mathematics
40 | - creating PDF slides
41 |
42 |
43 | How Does it Word?
44 | =================
45 |
46 | - Install MarkDoc (ssc install markdoc)
47 | - Install a full LaTeX distribution
48 | - provide the path to **pdfLaTeX** in the `printer()` option (see below)
49 | - Learn from this example!
50 |
51 |
52 |
53 |
54 | How about mathematics?
55 | ======================
56 |
57 | The dynamic slides are compiled with LaTeX and naturally,
58 | LaTeX mathematical notations are supported. Here is an example:
59 |
60 | - $f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n$
61 |
62 |
63 |
64 |
65 | How about Stata Output?
66 | ======================
67 |
68 | You can execute any command and present the outputs as well!
69 | ***/
70 |
71 | sysuse auto, clear
72 | tab price if price < 4000
73 |
74 | //OFF
75 | histogram price
76 | graph export graph.png, replace
77 | //ON
78 |
79 |
80 | /***
81 | Adding a graph
82 | ==========================
83 |
84 | 
85 |
86 |
87 |
88 | How to create more slides?
89 | ==========================
90 |
91 | - Every heading creates a new slide.
92 | - You can also use __#__ at the beginning of the line for creating a new slide.
93 | - or make a line with equal signs under a text line (see the code)
94 |
95 | ***/
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 | qui log c
104 |
105 | markdoc example, export(slide) replace // printer("PATH/TO/pdflatex")
106 |
--------------------------------------------------------------------------------
/mini_mode_tests/active_mini_mode/syntax1A.md:
--------------------------------------------------------------------------------
1 | . do test1.do
2 |
3 |
4 | Title 1
5 | =======
6 |
7 | **Hello** *World*!
8 |
9 | **hello** world! **what *the hell* is going on**! this is cool!
10 | ***we can also try a combination*** of these two! (_difficult_) **tests**.
11 | (*are*) also **WELCOMED**!
12 |
13 | And we can simple add multiple paragraphs? That is actually cool!
14 | In Markdown you can do a line break
15 | by adding 2 spaces at the end of the line
16 | without creating a new paragraph!
17 |
18 | Header 1
19 | ========
20 |
21 | Let's Try a code
22 | ----------------
23 |
24 | ### Code chunk!
25 |
26 | This is a code! **DO NOT INTERPRET**
27 | This is another code line
28 |
29 | Yet another one
30 |
31 | this is a paragraph again. We do not expect anything fuzzy here!
32 |
33 | Adding a figure with caption
34 | ----------------------------
35 |
36 | 
37 |
38 | Adding a table with **tbl** command
39 | -----------------------------------
40 |
41 | - - -
42 |
43 | - - -
44 |
45 |
46 | "Column1"|"Column2"|"Column3"
47 | :--------|:--------:|:--------:
48 | 4|5|6
49 | 7|8|9
50 | "OKOK"|"WHAT"|"NO WAY"
51 | "Let's try adding a long text here"|"and a semi long text here"|"NO WAY"
52 |
53 |
54 |
55 | ## Adding Indention
56 |
57 | You can also indent your text as well as do nested indention. Use the ">" sign
58 | at the beginning of the line to indent it.
59 |
60 | > this is a Markdown indention
61 |
62 | > > this is indention level 2
63 |
64 | > > > this is indention level 3
65 |
66 | Adding a list
67 | -------------
68 |
69 | Stata's **markdown** command supports Markdown lists and nesting lists.
70 | However, **putdocx** and **putpdf** do not support lists yet. There has been
71 | a workaround to support Markdown lists in **md2doc**. But nested lists are
72 | not yet implemented because they look rather ugly without a decent support
73 | of lists in the document...
74 |
75 | 1. This is a list
76 | 2. This is list 2
77 | 3. This is list 3
78 |
79 | - This is unordered list
80 | - This is also unordered list
81 |
82 | * These are paragraph breaks
83 | * And so is this one
84 |
85 | Code block
86 | ----------
87 |
88 | ~~~
89 | This is a code block
90 | anything
91 | written here
92 | will be preserved
93 | ~~~
94 |
95 |
96 |
97 | Limitations
98 | -----------
99 |
100 | Some of the Markdown syntax is **NOT** yet supported by Stata's **putdocx** or
101 | **putpdf** commands. These limitations are listed below:
102 |
103 | 1. horizontal line
104 | 2. Hyperlink
105 | 3. Nested lists
106 | 4. Mathematical notations
107 |
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/Torture_test/Examples/short.do:
--------------------------------------------------------------------------------
1 | /*
2 | MarkDoc Torture Test 001 : Main Features Test
3 | ---------------------------------------------
4 |
5 | Author: E. F. Haghish
6 | Institute for Medical Biometry and Statistics (IMBI)
7 | University of Freiburg
8 | http://haghish.com/stat
9 | @haghish
10 |
11 | Requirements: Install MarkDoc, Weaver, and Statax packages
12 | Install Pandoc and Wkhtmltopdf
13 | If you wish to produce PDF Slides, install a complete LaTeX
14 | */
15 |
16 | capture erase example.docx
17 |
18 | set scheme s1manual
19 | set linesize 80
20 | cap qui log c
21 |
22 | qui log using example, replace smcl
23 |
24 |
25 | /***
26 | MarkDoc Feature Test
27 | ====================
28 |
29 | This document attempts to check the main features of MarkDoc, for a broad
30 | assessment of the package before every new release.
31 | ***/
32 |
33 | sysuse auto, clear
34 | /***
35 | Text styling check
36 | ------------------
37 |
38 | _this is Italic_.
39 | __this is bold__.
40 | ___this is Italic and Bold___.
41 | `this text line should be in monospace font`.
42 |
43 | Variable check
44 | --------------
45 |
46 | Figure 1 shows the distribution of the __Price__ variable, followed by a
47 | regression analysis.
48 | ***/
49 |
50 | histogram price
51 | img, title("Figure 1. The histogram of the price variable")
52 | regress price mpg
53 | //OFF
54 | mat A = r(table)
55 | scalar p1 = A[4,1]
56 | //ON
57 | txt "As the output demonstrates, the average price of cars is " pmean " and " ///
58 | "the standard deviation is " psd ". The summary of the __price__ and " ///
59 | "__mpg__ variables is given in Table 1. " ///
60 | "Moreover, the regression analysis reveals the coefficient of the __mpg__ " ///
61 | "variable to be " coe1 " with a P-value of " p1 ", which is significant."
62 |
63 |
64 | //OFF
65 | qui summarize price
66 | scalar pnum = r(N)
67 | scalar pmean = r(mean)
68 | scalar psd = r(sd)
69 | qui summarize mpg
70 | //ON
71 |
72 | tbl ("__variable__", "__Observations__", "__Mean__", "__SD__" \ ///
73 | "__Price__", pnum, pmean, psd \ ///
74 | "__Mpg__", r(N), r(mean), r(sd) ), ///
75 | title("_Table 1_. Summary of the price and mpg variables")
76 |
77 |
78 | qui log c
79 | markdoc example, install replace export(docx) ///
80 | title("MarkDoc Main Features Test") author("E. F. Haghish") ///
81 | affiliation("IMBI, University of Freiburg") summary("This document presents " ///
82 | "the main features of [MarkDoc package], a multi-purpose package for creating " ///
83 | "dynamic PDF slides and analysis reports in many formats such as __pdf__, " ///
84 | "__docx__, __html__, __latex__, and __epub__. The package supports many " ///
85 | "features and recognizes three markup languages, which are Markdown, HTML, " ///
86 | "and LaTeX." )
87 |
88 |
--------------------------------------------------------------------------------
/Torture_test/rundoc/rundoc_example.markdown:
--------------------------------------------------------------------------------
1 | `rundoc` command
2 | ================
3 |
4 | The [`markdoc`](https://github.com/haghish/MarkDoc) command takes a
5 | `SMCL` log file to create a dynamic document or presentation slides.
6 | This procedure requires the user to create a log file and convert it to
7 | a dynamic document.
8 |
9 | The **`rundoc`** command, is simply a wrapper for MarkDoc to simplifies
10 | typesettinf dynamic documents directly from a Stata do-file, without
11 | requiring the do-file to include a log file.
12 |
13 | The syntax for writing comments remains identical to
14 | [`markdoc`](https://github.com/haghish/MarkDoc) command. This command
15 | should make executing dynamic documents much simpler!
16 |
17 | Features
18 | --------
19 |
20 | ### executing Stata commands
21 |
22 | The **`rundoc`** command preserves all of the features of `markdoc`,
23 | because it is simply a wrapper program. Therefore, it preserves all of
24 | the features of `markdoc` such as executing Stata commands and syntax
25 | highlighting of the Stata commands using
26 | [`statax`](https://github.com/haghish/statax) package:
27 |
28 | . display "Hello MarkDoc"
29 | Hello MarkDoc
30 |
31 | . sysuse auto, clear
32 | (1978 Automobile Data)
33 |
34 | . summarize
35 |
36 | Variable | Obs Mean Std. Dev. Min Max
37 | -------------+---------------------------------------------------------
38 | make | 0
39 | price | 74 6165.257 2949.496 3291 15906
40 | mpg | 74 21.2973 5.785503 12 41
41 | rep78 | 69 3.405797 .9899323 1 5
42 | headroom | 74 2.993243 .8459948 1.5 5
43 | -------------+---------------------------------------------------------
44 | trunk | 74 13.75676 4.277404 5 23
45 | weight | 74 3019.459 777.1936 1760 4840
46 | length | 74 187.9324 22.26634 142 233
47 | turn | 74 39.64865 4.399354 31 51
48 | displacement | 74 197.2973 91.83722 79 425
49 | -------------+---------------------------------------------------------
50 | gear_ratio | 74 3.014865 .4562871 2.19 3.89
51 | foreign | 74 .2972973 .4601885 0 1
52 |
53 |
54 |
55 | ### Writing mathematical notations
56 |
57 | Mathematical notations are supported in PDF, HTML, Docx, ODT
58 | (OpenOffice), and LaTeX:
59 |
60 | $$ Y = \beta_{0} + \beta_{1}x_{1} + \epsilon $$
61 |
--------------------------------------------------------------------------------
/mini_mode_tests/active_mini_mode/full1.do:
--------------------------------------------------------------------------------
1 |
2 |
3 | /***
4 | Workshop Example
5 | ================
6 |
7 | Subheader, Markdown syntax
8 | --------------------------
9 |
10 |
11 | This is a normal paragraph. We are trying to import
12 | an image to our document. The image is stored in the
13 | working directory. The syntax for importing an image
14 | is as follows
15 |
16 | 
17 |
18 | 
19 |
20 |
21 | There is a better way to include an image in the document. completely automatic!
22 | Let's start by creating a histogram and then using the `img` command:
23 |
24 | ***/
25 |
26 | sysuse auto, clear
27 | hist price
28 |
29 | /***
30 | ### Including an image
31 |
32 | Next, I am using the `img` command to automatically include the image in the
33 | document
34 | ***/
35 |
36 | img, title("Figure 1. say something about this figure")
37 |
38 |
39 | /***
40 | Writing dynamic text
41 | --------------------
42 |
43 | We can use the `txt` command to write dynamic text in our documnt.
44 | ***/
45 |
46 | summarize price
47 |
48 | /***
49 | I can use the `return list` command to see what macros are returned by the
50 | `summarize` command. These values will be printed:
51 | ***/
52 |
53 | return list
54 |
55 |
56 | txt "the mean of Price variable is " r(mean)
57 |
58 | txt "the minimum value is " r(min) " and the maximum is " r(max)
59 |
60 |
61 |
62 | /***
63 | Writing dynamic table
64 | --------------------
65 |
66 | We can use the `tbl` command to write dynamic tables. The `tbl` command generates
67 | the tables the same way Stata defines a matrix. To learn how Stata generate a
68 | matrix type:
69 |
70 | help matrix
71 | ***/
72 |
73 | tbl ("*italic 1*", "*italic 2*", "*italic 3*" \ ///
74 | "**boldtext1**", 100, 1000 \ ///
75 | "**boldtext2**", 22, 222 \ ///
76 | "**boldtext3**", 3948, 3948), title("Table 1. Styling a table")
77 |
78 |
79 | tbl ({l}"Left", {c}"Centered", {r}"Right" \ c(os), c(machine_type), c(username))
80 |
81 |
82 | /***
83 | #### Adding mathematical symbols in the dynamic table
84 |
85 | We have to use the LaTeX mathematical syntax, but they will be automatically
86 | converted in all documents generated by MarkDoc
87 | ***/
88 |
89 | tbl ("$\\beta$", "$95\\%$ Confidence Interval" \ "values...", "values...")
90 |
91 | tbl ("$\\beta$", "$\\epsilon$" \ "$\\sum$", "$\\prod$")
92 |
93 |
94 | /***
95 | Creating a summary table
96 | ------------------------
97 |
98 | I will use the macros returned from `summarize` command to build a nice table
99 | in my document:
100 | ***/
101 |
102 | summarize price
103 | return list
104 | tbl ("Variable", "Observations", "Mean", "SD" \ ///
105 | "__price__", r(N), %9.2f r(mean), %9.2f r(sd))
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/Examples/mini/slide.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | Title
4 | =====
5 |
6 | subtitle
7 | --------
8 |
9 | ---
10 |
11 | # Tables
12 |
13 | Your documents, slides, and help files can include tables!
14 |
15 | | Tables | style of table | Cool |
16 | | :-------------- |:-------------------- | :------ |
17 | | col 3 is | right-aligned | $1600 |
18 | | col 2 is | centered | $12 |
19 |
20 |
21 |
22 | You can also create your tables online. The website mentioned below produces
23 | the format that is "ideal" for MarkDoc
24 |
25 | | __Website__ | __URL__ |
26 | |--------------------|-------------------------------------------------|
27 | | _Tables Generator_ | https://www.tablesgenerator.com/markdown_tables |
28 |
29 | ---
30 |
31 | # Agenda
32 |
33 | 1. Introduction
34 | 2. Deep-dive
35 | 3. ...
36 |
37 | or unordered list:
38 |
39 | - Introduction
40 | - Deep-dive
41 | - ...
42 |
43 |
44 | ---
45 |
46 |
47 |
48 |
49 |
50 | . sysuse auto, clear
51 | (1978 Automobile Data)
52 |
53 | . summarize price mpg
54 |
55 | Variable | Obs Mean Std. Dev. Min Max
56 | -------------+---------------------------------------------------------
57 | price | 74 6165.257 2949.496 3291 15906
58 | mpg | 74 21.2973 5.785503 12 41
59 |
60 |
61 |
62 | This will start an __asis__ mode, which remember, it does not recognize "tabs".
63 | So until Stata fixes this problem, style your code with spaces rather than tabs.
64 |
65 | ~~~
66 |
67 | if main.r2.iseq(1) {
68 | call main.master.enable
69 | }
70 | else {
71 | call main.master.disable
72 | }
73 | ~~~
74 |
75 |
76 | ---
77 |
78 | # Introduction
79 |
80 |
81 | . reg price mpg
82 |
83 | Source | SS df MS Number of obs = 74
84 | -------------+---------------------------------- F(1, 72) = 20.26
85 | Model | 139449474 1 139449474 Prob > F = 0.0000
86 | Residual | 495615923 72 6883554.48 R-squared = 0.2196
87 | -------------+---------------------------------- Adj R-squared = 0.2087
88 | Total | 635065396 73 8699525.97 Root MSE = 2623.7
89 |
90 | ------------------------------------------------------------------------------
91 | price | Coef. Std. Err. t P>|t| [95% Conf. Interval]
92 | -------------+----------------------------------------------------------------
93 | mpg | -238.8943 53.07669 -4.50 0.000 -344.7008 -133.0879
94 | _cons | 11253.06 1170.813 9.61 0.000 8919.088 13587.03
95 | ------------------------------------------------------------------------------
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/make.do:
--------------------------------------------------------------------------------
1 | // the 'make.do' file is automatically created by 'github' package.
2 | // execute the code below to generate the package installation files.
3 | // DO NOT FORGET to update the version of the package, if changed!
4 | // for more information visit http://github.com/haghish/github
5 |
6 | make markdoc, replace toc pkg version(5.0.0) ///
7 | license("MIT") ///
8 | author("E. F. Haghish") ///
9 | affiliation("University of Goettingen") ///
10 | email("haghish@med.uni-goettingen.de") ///
11 | url("https://github.com/haghish/github") ///
12 | title("a general-purpose literate programming package") ///
13 | description("generate dynamic document, slides, stata help files, " ///
14 | "and package vignette in various formats") ///
15 | install("markdoc_formal.docx;markdoc_minimal.docx;markdoc_simple.docx;" ///
16 | "markdoc_stata.docx;markdoc_title.dlg;markdoc.ado;markdoc.dlg;" ///
17 | "markdoc.sthlp;markdoccheck.ado;markdocpandoc.ado;" ///
18 | "markdocstyle.ado;markdocversion.ado;markdocwkhtmltopdf.ado;" ///
19 | "markup.ado;mdconvert.ado;mdconvert.sthlp;mdminor.ado;" ///
20 | "mdminor.sthlp;mini.ado;mini.dlg;mini.sthlp;pandoc.ado;" ///
21 | "pandoc.sthlp;rundoc.ado;sthlp.ado;sthlp.sthlp;wkhtmltopdf.ado;" ///
22 | "wkhtmltopdf.sthlp") ///
23 | ancillary("")
24 |
25 |
26 |
27 | /*
28 | Generating the package documentation
29 | ====================================
30 |
31 | The package documentation is written in Markdown language. The MARKDOC package
32 | extract these documentation and create the Stata help files as well as Markdown
33 | documentation for GitHub Wiki. Learn more about MARKDOC here:
34 | https://github.com/haghish/markdoc
35 |
36 | Generating Stata Help Files
37 | ---------------------------
38 | */
39 |
40 | markdoc "markdoc.ado", mini export(sthlp) replace
41 | markdoc "mini.ado", mini export(sthlp) replace
42 | markdoc "mdconvert.ado", mini export(sthlp) replace
43 | markdoc "mdminor.ado", mini export(sthlp) replace
44 | markdoc "pandoc.ado", mini export(sthlp) replace
45 | markdoc "wkhtmltopdf.ado", mini export(sthlp) replace
46 |
47 | // generate the Markdown documentation for GitHub
48 | markdoc "markdoc.ado", mini export(md) replace
49 | markdoc "mini.ado", mini export(md) replace
50 | markdoc "mdconvert.ado", mini export(md) replace
51 | markdoc "mdminor.ado", mini export(md) replace
52 | markdoc "pandoc.ado", mini export(md) replace
53 | markdoc "wkhtmltopdf.ado", mini export(md) replace
54 |
55 | markdoc "vignette.do", export(tex) toc replace master ///
56 | title("markdoc v. 5.0 package vignette") ///
57 | author("E. F. Haghish")
58 |
--------------------------------------------------------------------------------
/Examples/dynamic_text/test2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
96 |
97 |
98 |
. sysuse auto, clear
99 | (1978 Automobile Data)
100 |
101 | . summarize foreign
102 |
103 | Variable | Obs Mean Std. Dev. Min Max
104 | -------------+---------------------------------------------------------
105 | foreign | 74 .2972973 .4601885 0 1
106 |
107 | . scalar c = "Dynamic"
108 |
109 | . local min = `r(min)'
110 |
111 | . scalar max = r(max)
112 |
Dynamic text
113 |
The documentation can include numeric and string macros and scalars. For example, the values of the foreign variable range between 0 to 1.
114 |
115 |
116 |
--------------------------------------------------------------------------------
/Torture_test/Beamer/Stata programs.do:
--------------------------------------------------------------------------------
1 | cap erase programming_course.pdf
2 | capture log c
3 | qui log using programming_course, replace
4 |
5 |
6 | /***
7 | ---
8 | title: "Stata, as a programming language"
9 | author: E. F. Haghish
10 |
11 | date: March 2016
12 |
13 | fontsize: 14pt
14 |
15 | output:
16 | beamer_presentation:
17 | theme: "Boadilla"
18 | colortheme: "lily"
19 | fonttheme: "structurebold"
20 |
21 | includes:
22 | in_header: body.tex
23 | ---
24 |
25 | ABout the workshop
26 | ================================
27 |
28 | - Reviewing different features of Stata programming language
29 |
30 | - Giving examples and homework for each feature
31 |
32 | - The workshop is completely lab-based, teaching solutions to actual problems
33 |
34 |
35 | ABout the workshop
36 | ================================
37 |
38 | - The workshop includes a number of "problems" categorized as
39 | Beginner, Intermediate, and Advanced level
40 |
41 | - The solutions are already provided, but you should make an attempt for
42 | solving them yourself
43 |
44 | - After each problem, we discuss possible solutions and we spend a few minutes
45 | programming
46 |
47 | - I will cover a wide-range of programs
48 |
49 |
50 | Beginner Level
51 | ================================================================================
52 |
53 |
54 |
55 | Intermediate Level
56 | ================================================================================
57 |
58 |
59 | Problem 1 : File
60 | ================
61 |
62 | "file allows programmers to read and write both text and binary files, so file
63 | could be used to write a program to input data in some complicated situation.
64 | Files are referred to by a file handle. When you open a file, you specify the
65 | file handle that you want to use"
66 |
67 | - read the following file with the program and count the number of lines!
68 | "https://raw.githubusercontent.com/haghish/MarkDoc/master/README.md"
69 |
70 | - Write an ado program that reads a file and counts the number of lines
71 |
72 |
73 | Solution
74 | ================
75 | ***/
76 |
77 | capture program drop countline
78 | program countline
79 | syntax using/
80 | tempname handle
81 | file open `handle' using `"`using'"', read
82 | file read `handle' line
83 | local lnum 0
84 | while r(eof) == 0 {
85 | file read `handle' line
86 | local lnum `++lnum'
87 | }
88 | file close `handle'
89 | display as txt "(the file includes {bf:`lnum'} lines)"
90 | end
91 |
92 | countline using "https://raw.githubusercontent.com/haghish/MarkDoc/master/README.md"
93 |
94 |
95 |
96 | /***
97 | Advanced Level
98 | ================================================================================
99 |
100 | Problem 1 : File
101 | ================
102 |
103 | In the first problem of the intermediate level, we wrote a program that opens
104 | a file and counts the number of lines. Rewrite that program with Mata
105 |
106 |
107 |
108 | ***/
109 |
110 |
111 |
112 | qui log c
113 | markdoc programming_course, export(slide) replace linesize(120)
114 |
115 |
116 |
--------------------------------------------------------------------------------
/putpdf_colors.do:
--------------------------------------------------------------------------------
1 | local namelist aliceblue ghostwhite navajowhite ///
2 | antiquewhite gold navy ///
3 | aqua goldenrod oldlace ///
4 | aquamarine gray olive ///
5 | azure green olivedrab ///
6 | beige greenyellow orange ///
7 | bisque honeydew orangered ///
8 | black hotpink orchid ///
9 | blanchedalmond indianred palegoldenrod ///
10 | blue indigo palegreen ///
11 | blueviolet ivory paleturquoise ///
12 | brown khaki palevioletred ///
13 | burlywood lavender papayawhip ///
14 | cadetblue lavenderblush peachpuff ///
15 | chartreuse lawngreen peru ///
16 | chocolate lemonchiffon pink ///
17 | coral lightblue plum ///
18 | cornflowerblue lightcoral powderblue ///
19 | cornsilk lightcyan purple ///
20 | crimson lightgoldenrodyellow red ///
21 | cyan lightgray rosybrown ///
22 | darkblue lightgreen royalblue ///
23 | darkcyan lightpink saddlebrown ///
24 | darkgoldenrod lightsalmon salmon ///
25 | darkgray lightseagreen sandybrown ///
26 | darkgreen lightskyblue seagreen ///
27 | darkkhaki lightslategray seashell ///
28 | darkmagenta lightsteelblue sienna ///
29 | darkolivegreen lightyellow silver ///
30 | darkorange lime skyblue ///
31 | darkorchid limegreen slateblue ///
32 | darkred linen slategray ///
33 | darksalmon magenta snow ///
34 | darkseagreen maroon springgreen ///
35 | darkslateblue mediumaquamarine steelblue ///
36 | darkslategray mediumblue tan ///
37 | darkturquoise mediumorchid teal ///
38 | darkviolet mediumpurple thistle ///
39 | deeppink mediumseagreen tomato ///
40 | deepskyblue mediumslateblue turquoise ///
41 | dimgray mediumspringgreen violet ///
42 | dodgerblue mediumturquoise wheat ///
43 | firebrick mediumvioletred white ///
44 | floralwhite midnightblue whitesmoke ///
45 | forestgreen mintcream yellow ///
46 | fuchsia mistyrose yellowgreen ///
47 | gainsboro moccasin
48 |
49 | putpdf clear
50 | putpdf begin
51 | putpdf paragraph
52 |
53 | tokenize "`namelist'"
54 | while "`1'" != "" {
55 | putpdf text ("`1'"), font("", 14, `1') linebreak
56 | macro shift
57 | }
58 |
59 | putpdf save putpdf_colors, replace
60 |
--------------------------------------------------------------------------------
/Resources/images/announcement2.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
65 |
--------------------------------------------------------------------------------
/Torture_test/Examples/main_features.do:
--------------------------------------------------------------------------------
1 | capture erase example.docx
2 |
3 | /*
4 | MarkDoc Torture Test 001 : Main Features Test
5 | ---------------------------------------------
6 |
7 | Author: E. F. Haghish
8 | Institute for Medical Biometry and Statistics (IMBI)
9 | University of Freiburg
10 | http://haghish.com/stat
11 | @haghish
12 |
13 | Requirements: Install MarkDoc, Weaver, and Statax packages
14 | Install Pandoc and Wkhtmltopdf
15 | If you wish to produce PDF Slides, install a complete LaTeX
16 | */
17 |
18 | set scheme s1manual
19 | set linesize 80
20 | cap qui log c
21 |
22 | sysuse auto, clear
23 |
24 | qui log using example, replace smcl
25 |
26 |
27 | /***
28 | MarkDoc Feature Test
29 | ====================
30 |
31 | Editable mathematical notations
32 | -------------------------------
33 |
34 | Documenting statistical software or even teaching statistics often requires
35 | some mathematical discussions. The notation can be included in the output
36 | dynamically!
37 |
38 | $f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n$
39 |
40 |
41 | Figure 1 shows the distribution of the __Price__ variable, followed by a
42 | regression analysis.
43 | ***/
44 |
45 | histogram price
46 | img, title("Figure 1. The histogram of the price variable")
47 | regress price mpg
48 | //OFF
49 | mat A = r(table)
50 | scalar p1 = A[4,1]
51 | //ON
52 | txt "As the output demonstrates, the average price of cars is " pmean " and " ///
53 | "the standard deviation is " psd ". The summary of the __price__ and " ///
54 | "__mpg__ variables is given in Table 1. " ///
55 | "Moreover, the regression analysis reveals the coefficient of the __mpg__ " ///
56 | "variable to be " coe1 " with a P-value of " p1 ", which is significant."
57 |
58 |
59 | //OFF
60 | qui summarize price
61 | scalar pnum = r(N)
62 | scalar pmean = r(mean)
63 | scalar psd = r(sd)
64 | qui summarize mpg
65 | //ON
66 |
67 | tbl ("__variable__", "__Observations__", "__Mean__", "__SD__" \ ///
68 | "__Price__", pnum, pmean, psd \ ///
69 | "__Mpg__", r(N), r(mean), r(sd) ), ///
70 | title("_Table 1_. Summary of the price and mpg variables")
71 |
72 |
73 | qui log c
74 |
75 | markdoc example, install replace export(docx) ///
76 | title("MarkDoc Main Features Test") author("E. F. Haghish") ///
77 | affiliation("IMBI, University of Freiburg") summary("This document presents " ///
78 | "the main features of [MarkDoc package](http://www.haghish.com/markdoc), " ///
79 | "a multi-purpose package for creating dynamic PDF slides and analysis reports " ///
80 | "in many formats such as __pdf__, __docx__, __html__, __latex__, and " ///
81 | "__epub__. The package supports many features and recognizes three markup " ///
82 | "languages, which are Markdown, HTML, and LaTeX." )
83 |
84 | markdoc example, install replace export(slide) ///
85 | title("MarkDoc Main Features Test") author("E. F. Haghish") ///
86 | affiliation("IMBI, University of Freiburg") summary("This document presents " ///
87 | "the main features of [MarkDoc package](http://www.haghish.com/markdoc), " ///
88 | "a multi-purpose package for creating dynamic PDF slides and analysis reports " ///
89 | "in many formats such as __pdf__, __docx__, __html__, __latex__, and " ///
90 | "__epub__. The package supports many features and recognizes three markup " ///
91 | "languages, which are Markdown, HTML, and LaTeX." )
92 |
--------------------------------------------------------------------------------
/Torture_test/Beamer/Beamer.do:
--------------------------------------------------------------------------------
1 | //capture prog drop markdoc
2 | capture erase example.pdf
3 |
4 | sysuse auto, clear
5 | capture log c
6 | qui log using example, replace
7 | /***
8 |
9 | ---
10 | title: "Dynamic Slides in MarkDoc Package"
11 | author: E. F. Haghish
12 | date: or anything else
13 | fontsize: 14pt
14 |
15 | output:
16 | beamer_presentation:
17 | theme: "Boadilla"
18 | colortheme: "lily"
19 | fonttheme: "structurebold"
20 |
21 | includes:
22 | in_header: body.tex
23 | ---
24 |
25 | Creating dynamic slides in Stata
26 | ================================
27 |
28 | - Dynamic slides are slides created for statistical representation and thus,
29 | includes code and output from Stata.
30 |
31 | - The __`markdoc`__ command allows you to
32 | easily create a _smcl log file_ and use it for creating dynamic analysis
33 | reports or even PDF slides. In this tutorial I will demonstrate how to quickly
34 | create the slides from Stata. Here are a few capabilities of the package.
35 |
36 |
37 | About MarkDoc
38 | =============
39 |
40 | MarkDoc is a general purpose literate programming package that can export
41 | dynamic reports in several formats within Stata. However, this tutorial only
42 | demonstrates the dynamic slide feature.
43 |
44 | - Adding images and figures
45 | - Interpreting mathematics
46 | - creating PDF slides
47 |
48 |
49 | How Does it Word?
50 | =================
51 |
52 | - Install MarkDoc (ssc install markdoc)
53 | - Install a full LaTeX distribution
54 | - Learn from this example!
55 |
56 |
57 |
58 |
59 | How about mathematics?
60 | ======================
61 |
62 | The dynamic slides are compiled with \LaTeX{} and naturally,
63 | \LaTeX{} mathematical notations are supported. Here is an example:
64 |
65 | - $f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n$
66 |
67 |
68 |
69 |
70 | How about Stata Output?
71 | ======================
72 |
73 | You can execute any command and present the outputs as well!
74 | ***/
75 |
76 |
77 | tab price if price < 4000
78 |
79 |
80 |
81 | /***
82 | How to create more slides?
83 | ==========================
84 |
85 | Every heading creates a new slide. You can also use __#__ at the beginning of
86 | the line for creating a new slide
87 |
88 |
89 |
90 |
91 | # How about wider Stata outputs
92 |
93 | if you use commands that produce wider tables, reduce the __fontsize__
94 | at the beginning of the document to keep the output within the document.
95 |
96 | ***/
97 |
98 |
99 |
100 | qui log c
101 |
102 | //capture prog drop markdoc
103 | markdoc example, export(slide) replace
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 | exit
112 |
113 | cap erase example.pdf
114 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer source.md -V theme:Boadilla -V ///
115 | colortheme:lily -V fontsize=8pt -o example.pdf
116 |
117 |
118 |
119 | exit
120 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer source.md -V theme:AnnArbor -V fontsize=9pt -o example.pdf
121 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer example.md -V theme:AnnArbor -o example.pdf
122 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer example.md -V theme:Warsaw -o example01.pdf
123 |
124 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer source.md -o example01.pdf
125 |
--------------------------------------------------------------------------------
/Torture_test/Beamer/Beamer3.do:
--------------------------------------------------------------------------------
1 | //capture prog drop markdoc
2 | capture erase example.pdf
3 |
4 | sysuse auto, clear
5 | capture log c
6 | qui log using example, replace
7 | /***
8 |
9 | ---
10 | title: "Dynamic Slides in MarkDoc Package"
11 | author: E. F. Haghish
12 | date: February 2016
13 | fontsize: 14pt
14 |
15 | output:
16 | beamer_presentation:
17 | theme: "CambridgeUS"
18 | colortheme: "lily"
19 | fonttheme: "structurebold"
20 |
21 | includes:
22 | in_header: body.tex
23 | ---
24 |
25 | Creating dynamic slides in Stata
26 | ================================
27 |
28 | ### header 3
29 | - Dynamic slides are slides created for statistical representation and thus,
30 | includes code and output from Stata.
31 |
32 | - The __`markdoc`__ command allows you to
33 | easily create a _smcl log file_ and use it for creating dynamic analysis
34 | reports or even PDF slides. In this tutorial I will demonstrate how to quickly
35 | create the slides from Stata. Here are a few capabilities of the package.
36 |
37 |
38 | About MarkDoc
39 | =============
40 |
41 | #### Header 4
42 |
43 | MarkDoc is a general purpose literate programming package that can export
44 | dynamic reports in several formats within Stata. However, this tutorial only
45 | demonstrates the dynamic slide feature.
46 |
47 | - Adding images and figures
48 | - Interpreting mathematics
49 | - creating PDF slides
50 |
51 |
52 | How Does it Word?
53 | =================
54 |
55 | - Install MarkDoc (ssc install markdoc)
56 | - Install a full LaTeX distribution
57 | - Learn from this example!
58 |
59 |
60 |
61 |
62 | How about mathematics?
63 | ======================
64 |
65 | The dynamic slides are compiled with \LaTeX{} and naturally,
66 | \LaTeX{} mathematical notations are supported. Here is an example:
67 |
68 | - $f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n$
69 |
70 |
71 |
72 |
73 | How about Stata Output?
74 | ======================
75 |
76 | You can execute any command and present the outputs as well!
77 | ***/
78 |
79 |
80 | tab price if price < 4000
81 |
82 |
83 |
84 | /***
85 | How to create more slides?
86 | ==========================
87 |
88 | Every heading creates a new slide. You can also use __#__ at the beginning of
89 | the line for creating a new slide
90 |
91 |
92 |
93 |
94 | # How about wider Stata outputs
95 |
96 | if you use commands that produce wider tables, reduce the __fontsize__
97 | at the beginning of the document to keep the output within the document.
98 |
99 | ***/
100 |
101 |
102 |
103 | qui log c
104 |
105 | //capture prog drop markdoc
106 | markdoc example, export(slide) replace
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 | exit
115 |
116 | cap erase example.pdf
117 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer source.md -V theme:Boadilla -V ///
118 | colortheme:lily -V fontsize=8pt -o example.pdf
119 |
120 |
121 |
122 | exit
123 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer source.md -V theme:AnnArbor -V fontsize=9pt -o example.pdf
124 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer example.md -V theme:AnnArbor -o example.pdf
125 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer example.md -V theme:Warsaw -o example01.pdf
126 |
127 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer source.md -o example01.pdf
128 |
--------------------------------------------------------------------------------
/Examples/Mathematics/example.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
88 |
89 |
90 |
Use a single "$" sign for writing inline mathematical notations. For example, \(f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n\) would be rendered inline with the text paragraph. Use double dollar signs "$$" for placing the notations on a separate lines:
91 |
\[Y_i = \beta_0 + \beta_1 X_i + \epsilon_i\]
92 |
93 |
Since the notations appear in comments, they will not be interpreted by Stata as global macros.
94 |
Place a backslash before the "$" if you are using them in the document, but not for rendering mathematical notations. The backslash will not appear in the dynamic document.
95 |
You can also write dynamic mathematical notations using the txt command.
96 |
. local a = 10
97 |
98 |
\[ \beta_1 = 10 \]
99 |
Note that when you write inline mathematical notations, there should be NO SPACE between the dollar sign and the notation. However, if you are placing your notations on a separate line, there should be no problem.
100 |
101 |
102 |
--------------------------------------------------------------------------------
/Examples/mini/doc.do:
--------------------------------------------------------------------------------
1 | // 1. change the working directory to where this file is saved
2 | // Execute this file with markdoc mini to create dynamic document/slides/sthlp
3 |
4 | /***
5 | Header
6 | ======
7 |
8 | something will appear
9 |
10 | ---
11 |
12 | Header 2
13 | --------
14 |
15 | ### Header 3
16 |
17 | #### Header 4
18 |
19 | ##### Header 5
20 |
21 | ---
22 |
23 | Part 2
24 | =======
25 |
26 | This is a text paragraph. Text can be *italic* or
27 | _italic_. Also, it can be **Bold** or __Bold__.
28 |
29 | > "the text paragraph can be indented for - typically -quoting "
30 |
31 | - This is item 1
32 | - Item 2
33 | - item 3
34 | - This is another item
35 | - quite file I hope
36 | - continue with the list
37 |
38 | ---
39 |
40 | Numbered list
41 | ==============
42 |
43 | 1. numbered item 1
44 | 2. item 2
45 | 3. back to item
46 |
47 | Using the "---" sign will add a line in the document
48 |
49 | ---
50 |
51 | Breaking the line
52 | -----------------
53 |
54 | Add 2 or more spaces at the end of the line to break it without
55 | starting
56 | a new
57 | paragraph
58 |
59 |
60 | ---
61 |
62 |
63 | Adding links
64 | -------------
65 |
66 | You can also add the __hypertext__ e.g.
67 | [MarDoc's Manual](https://github.com/haghish/MarkDoc/wiki)
68 |
69 | ---
70 |
71 | ***/
72 |
73 | sysuse auto, clear //load auto dataset
74 |
75 | summarize
76 |
77 | /***
78 | ---
79 | ***/
80 |
81 | histogram price
82 | graph export price_hist.png, replace width(300)
83 |
84 | /***
85 | Including a figure
86 | ------------------
87 |
88 | Next, I include the histogram of the Price variable using
89 | the `histogram` command and the `price` variable.
90 |
91 | ---
92 |
93 | 
94 |
95 | ***/
96 |
97 |
98 | // reloading the same image using `img` command:
99 |
100 | *img using "price_hist.png", title("explain your graph")
101 |
102 |
103 | histogram mpg
104 |
105 | img, title("Figure 2. Histogram of the `mpg` variable")
106 |
107 |
108 | /***
109 |
110 | ---
111 |
112 | Writing dynamic text
113 | --------------------
114 |
115 | use the `txt` command to interpret values of macros and scalars:
116 | ***/
117 |
118 | summarize price
119 | return list
120 |
121 | txt "The number of subject is " r(N) " subjects in the darta set. "
122 |
123 |
124 | /***
125 |
126 | ---
127 |
128 | creating table
129 | ---------------
130 |
131 | This table is also supported in __sthlp__ help files
132 |
133 | | __Optopns__ | __Discription__ |
134 | |-------------|------------------------------------------------------------------|
135 | | markup(str) | specifies the markup language that is used for documentation |
136 | | title(str) | displays the table description |
137 | | width(int) | specifies the width of the table in HTML and LaTeX |
138 | | height(int) | specifies the height of the table in HTML and LaTeX |
139 | | center | aligns the table to the center of the document in HTML and LaTeX |
140 | | left | aligns the table to the left of the document |
141 |
142 | ---
143 |
144 | Mathematical notations
145 | ======================
146 |
147 | You can use markdoc to:
148 |
149 | 1. write inline notations (i.e. in the text paragraphs)
150 | 2. on a separate line
151 |
152 | For example, $\sum$ will appear inline whereas $$\sum$$ willbe on another line.
153 |
154 |
155 | ***/
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
--------------------------------------------------------------------------------
/mini_mode_tests/active_mini_mode/summary.do:
--------------------------------------------------------------------------------
1 | // this document produces the dynamic document passively, because a log-file is
2 | // used to generate the PDF file, instead of a do-file!
3 |
4 |
5 |
6 | qui log using summary, replace
7 |
8 | /***
9 |
10 | Notes
11 | --------
12 |
13 | Here are a few important notes
14 |
15 | 1. As I noted, I have a book about `markdoc` that is nearly finished. I will
16 | send the PDF of the book to Dennis and kindly ask him to put send it to all
17 | of participants of the course. The book is very detailed and has many examples,
18 | and giving it to you is the least I can do to appologize from those few who
19 | had issues with installing the software on their computer and could not fully
20 | benefit from the course. I am certain that the book will provide much more
21 | details as well as examples about MarkDoc and will get everyone going.
22 |
23 | 2. `markdoc` has an option named `noisily`. If you are using the GUI, make sure
24 | the box that says `Execute MarkDoc noisily` is not checked. If you check this
25 | box, your report will be very noisy with information you did not ask for,
26 | because this option is for debugging. I remember some people asked me why they
27 | get extra information while others do not...
28 |
29 | 3. On Mac and Linux, the file path is specified with slash. On Microsoft Windows,
30 | with backslash. Therefore, anyone with Microsoft Windows who could not execute
31 | my example of `markdoc ./filename, ...` hat to actually type
32 | `markdoc .\filename, ...` on Microsoft Windows. This was so obvious, yet at the
33 | time of the presentation it didn't occure to me.
34 |
35 |
36 | Summary of Workshop
37 | ===================
38 |
39 | In the workshop, we covered multiple topics regarding `markdoc` package. Most
40 | notably, we learned about:
41 |
42 | 1. Markdown markup language. We also practiced the syntax at John Gruber's
43 | website which was .
44 |
45 | 2. We talked about writing dynamic text and adding figures in the document
46 | automatically. If you would like to know more about the `txt` and `img` commands,
47 | type:
48 |
49 | help txt
50 | help img
51 |
52 | 3. We also talked about the `tbl` command for building and styling dynamic tables
53 | that can be exported to any document format. To learn more about the `tbl` command
54 | type:
55 |
56 | help tbl
57 |
58 | 4. We also talked about using `markdoc` for generating presentation slides.
59 |
60 | 5. Most of the participants were interested in using `markdoc` for writing dynamic
61 | tables. Therefore, I have prepared additional examples for writing and styling
62 | dynamic tables. These examples will be available on markdoc's manual website soon.
63 |
64 |
65 | Resources
66 | ---------
67 |
68 |
69 | There are several resources that you can practice `markdoc` package. These
70 | resources are:
71 |
72 | - [markdoc's journal article](https://www.stata-journal.com/article.html?article=pr0064)
73 | - [markdoc's GitHub Wiki](https://github.com/haghish/markdoc/wiki)
74 | - [markdoc's vignette](https://github.com/haghish/markdoc/raw/master/Help/Help.pdf)
75 |
76 | ---
77 |
78 |
79 | If you have any question regarding `markdoc`, please kindly post it on
80 | , there is a rather big community of markdoc users
81 | there and I also regularly respond to the questions on this website.
82 | You can also reach me via email
83 |
84 | ***/
85 |
86 |
87 | qui log c
88 | markdoc summary.smcl, export(pdf) replace style("formal") ///
89 | title("Summary of the workshop") author("E. F. Haghish") ///
90 | affiliation("University of Göttingen") ///
91 | address("haghish@med.uni-goettingen.de")
92 |
--------------------------------------------------------------------------------
/Examples/Dynamic Slides/slide.do:
--------------------------------------------------------------------------------
1 | // Execute this file to create dynamic slides. Remember that you will need
2 | // pdfLaTeX to be installed
3 |
4 |
5 |
6 | /***
7 | Header
8 | ======
9 |
10 | sthing will appear
11 |
12 | Header 2
13 | --------
14 |
15 | ### Header 3
16 |
17 | #### Header 4
18 |
19 | ##### Header 5
20 |
21 | Part 2
22 | =======
23 |
24 |
25 | This is a text paragraph. Text can be *italic* or
26 | _italic_. Also, it can be **Bold** or __Bold__.
27 |
28 | > "the text paragraph can be indented for - typically -quoting "
29 |
30 | - This is item 1
31 | - Item 2
32 | - item 3
33 | * This is another item
34 | - quite file I hope
35 | - sublist item 1
36 | - sublist 2
37 | - subsublist 1
38 | - item
39 | 1. sth
40 | 2. sth
41 | - continue with sublist
42 | - continue with the list
43 |
44 |
45 | Numbered list
46 | ==============
47 |
48 | 1. numbered item 1
49 | 2. item 2
50 | 1. subitem 1
51 | 2. subitem 2
52 | 2. subsub item
53 | 2. sth
54 | 3. back to item
55 |
56 | Using the "---" sign will add a line in the document
57 |
58 | ---
59 |
60 | Breaking the line
61 | -----------------
62 |
63 | Add 2 or more spaces at the end of the line to break it without
64 | starting
65 | a new
66 | paragraph
67 |
68 |
69 | ---
70 |
71 |
72 | Adding links
73 | -------------
74 |
75 | This is a link to MarkDoc's GitHub Manual
76 |
77 |
78 | You can also change the __hypertext__ e.g.
79 | [MarDoc's Manual](https://github.com/haghish/MarkDoc/wiki)
80 |
81 | ---
82 |
83 | ***/
84 |
85 | sysuse auto, clear //load auto dataset
86 |
87 | summarize
88 |
89 | /***
90 | ---
91 | ***/
92 |
93 | histogram price
94 | graph export price_hist.png, replace width(300)
95 |
96 | /***
97 | Including a figure
98 | ------------------
99 |
100 | Next, I include the histogram of the Price variable using
101 | the `histogram` command and the `price` variable.
102 |
103 | ---
104 |
105 | 
106 |
107 | ***/
108 |
109 |
110 | // reloading the same image using `img` command:
111 |
112 | *img using "price_hist.png", title("explain your graph")
113 |
114 |
115 | histogram mpg
116 |
117 | img, title("Figure 2. Histogram of the `mpg` variable")
118 |
119 |
120 | /***
121 |
122 | ---
123 |
124 | Writing dynamic text
125 | --------------------
126 |
127 | use the `txt` command to interpret values of macros and scalars:
128 | ***/
129 |
130 | summarize price
131 | return list
132 |
133 | txt "The number of subject is " r(N) " subjects in the darta set. "
134 |
135 |
136 | /***
137 |
138 | ---
139 |
140 | creating table
141 | ---------------
142 |
143 |
144 | | __Optopns__ | __Discription__ |
145 | |-------------|------------------------------------------------------------------|
146 | | markup(str) | specifies the markup language that is used for documentation |
147 | | title(str) | displays the table description |
148 | | width(int) | specifies the width of the table in HTML and LaTeX |
149 | | height(int) | specifies the height of the table in HTML and LaTeX |
150 | | center | aligns the table to the center of the document in HTML and LaTeX |
151 | | left | aligns the table to the left of the document |
152 |
153 | --
154 |
155 | size material color
156 | ---- ------------ ------------
157 | 9 leather brown
158 | 10 hemp canvas natural
159 | 11 glass transparent
160 |
161 |
162 | Mathematical notations
163 | ======================
164 |
165 | You can use markdoc to:
166 |
167 | 1. write inline notations (i.e. in the text paragraphs)
168 | 2. on a separate line
169 |
170 | For example, $\sum$ will appear inline whereas $$\sum$$ willbe on another line.
171 |
172 |
173 | ***/
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
--------------------------------------------------------------------------------
/Examples/Dynamic Slides/example.do:
--------------------------------------------------------------------------------
1 | // Execute this file to create dynamic slides. Remember that you will need
2 | // pdfLaTeX to be installed
3 |
4 |
5 |
6 | /***
7 | Header
8 | ======
9 |
10 | sthing will appear
11 |
12 | Header 2
13 | --------
14 |
15 | ### Header 3
16 |
17 | #### Header 4
18 |
19 | ##### Header 5
20 |
21 | Part 2
22 | =======
23 |
24 |
25 | This is a text paragraph. Text can be *italic* or
26 | _italic_. Also, it can be **Bold** or __Bold__.
27 |
28 | > "the text paragraph can be indented for - typically -quoting "
29 |
30 | - This is item 1
31 | - Item 2
32 | - item 3
33 | * This is another item
34 | - quite file I hope
35 | - sublist item 1
36 | - sublist 2
37 | - subsublist 1
38 | - item
39 | 1. sth
40 | 2. sth
41 | - continue with sublist
42 | - continue with the list
43 |
44 |
45 | Numbered list
46 | ==============
47 |
48 | 1. numbered item 1
49 | 2. item 2
50 | 1. subitem 1
51 | 2. subitem 2
52 | 2. subsub item
53 | 2. sth
54 | 3. back to item
55 |
56 | Using the "---" sign will add a line in the document
57 |
58 | ---
59 |
60 | Breaking the line
61 | -----------------
62 |
63 | Add 2 or more spaces at the end of the line to break it without
64 | starting
65 | a new
66 | paragraph
67 |
68 |
69 | ---
70 |
71 |
72 | Adding links
73 | -------------
74 |
75 | This is a link to MarkDoc's GitHub Manual
76 |
77 |
78 | You can also change the __hypertext__ e.g.
79 | [MarDoc's Manual](https://github.com/haghish/MarkDoc/wiki)
80 |
81 | ---
82 |
83 | ***/
84 |
85 | sysuse auto, clear //load auto dataset
86 |
87 | summarize
88 |
89 | /***
90 | ---
91 | ***/
92 |
93 | histogram price
94 | graph export price_hist.png, replace width(300)
95 |
96 | /***
97 | Including a figure
98 | ------------------
99 |
100 | Next, I include the histogram of the Price variable using
101 | the `histogram` command and the `price` variable.
102 |
103 | ---
104 |
105 | 
106 |
107 | ***/
108 |
109 |
110 | // reloading the same image using `img` command:
111 |
112 | *img using "price_hist.png", title("explain your graph")
113 |
114 |
115 | histogram mpg
116 |
117 | img, title("Figure 2. Histogram of the `mpg` variable")
118 |
119 |
120 | /***
121 |
122 | ---
123 |
124 | Writing dynamic text
125 | --------------------
126 |
127 | use the `txt` command to interpret values of macros and scalars:
128 | ***/
129 |
130 | summarize price
131 | return list
132 |
133 | txt "The number of subject is " r(N) " subjects in the darta set. "
134 |
135 |
136 | /***
137 |
138 | ---
139 |
140 | creating table
141 | ---------------
142 |
143 |
144 | | __Optopns__ | __Discription__ |
145 | |-------------|------------------------------------------------------------------|
146 | | markup(str) | specifies the markup language that is used for documentation |
147 | | title(str) | displays the table description |
148 | | width(int) | specifies the width of the table in HTML and LaTeX |
149 | | height(int) | specifies the height of the table in HTML and LaTeX |
150 | | center | aligns the table to the center of the document in HTML and LaTeX |
151 | | left | aligns the table to the left of the document |
152 |
153 | --
154 |
155 | size material color
156 | ---- ------------ ------------
157 | 9 leather brown
158 | 10 hemp canvas natural
159 | 11 glass transparent
160 |
161 |
162 | Mathematical notations
163 | ======================
164 |
165 | You can use markdoc to:
166 |
167 | 1. write inline notations (i.e. in the text paragraphs)
168 | 2. on a separate line
169 |
170 | For example, $\sum$ will appear inline whereas $$\sum$$ willbe on another line.
171 |
172 |
173 | ***/
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
--------------------------------------------------------------------------------
/Torture_test/test/helptest.sthlp:
--------------------------------------------------------------------------------
1 | {smcl}
2 | {right:version 1.0.0}
3 | {title:Title}
4 |
5 | {phang}
6 | {bf:myprogram }{hline 2} A new module for to print text. This description can include multiple lines, but not several paragraphs. You may write the title section in multiple lines. {help MarkDoc} will connect the lines to create only a single paragraph. If you{c 39}d like to describe the package more, create a description section below this header.
7 |
8 |
9 | {title:Author}
10 |
11 | {p 4 4 2}
12 | E. F. Haghish{break}
13 | University of Freiburg{break}
14 | haghish@imbi.uni-freiburg.de{break}
15 | {browse "http://www.haghish.com/markdoc"}{break}
16 |
17 |
18 | {title:Syntax}
19 |
20 | {p 8 16 2}
21 | {opt myprogram} [{it:anything}] [, {opt b:old} {opt i:talic}]
22 |
23 | {synoptset 20 tabbed}{...}
24 | {synopthdr}
25 | {synoptline}
26 | {synopt :{opt b:old}}prints bold text{p_end}
27 | {synopt :{opt i:talic}}prints italic text{p_end}
28 | {synoptline}
29 |
30 |
31 |
32 | {p}
33 | Typically, the text paragraphs in Stata help files begin with an indention, which makes the help file easier to read (and that{c 39}s important). To do so, place a {bf:{c -(}p 4 4 2{c )-}} directive above the line to indent the text paragraph and you{c 39}re good to go.
34 |
35 | {p}
36 | this is a text paragraph that is processing {bf:Markdown}, {it:italic text} or {ul:underscored text}. The only thing left is the link! but how far can this {bf:text styling go}? I mean how far does the rabit whole go? do you have any idea?
37 |
38 |
39 | {hline}
40 |
41 | {p}
42 | this is a text paragraph that is processing {bf:Markdown}, {it:italic text} or {ul:underscored text}. The only thing left is the link! but how far can this {bf:text styling go}? I mean how far does the rabit whole go? do you have any idea?
43 |
44 |
45 | {p 4 4 2}
46 | this is a text paragraph that is processing {bf:Markdown}, {it:italic text} or {ul:underscored text}. The only thing left is the link! but how far can this {bf:text styling go}? I mean how far does the rabit whole go? do you have any idea?
47 |
48 |
49 |
50 | {title:Another heading }
51 |
52 | {p 4 4 2}
53 | Typically, the text paragraphs in Stata help files begin with an indention,
54 | which makes the help file easier to read (and that's important). To do so,
55 | place a {bf:{c -(}p 4 4 2{c )-}} directive above the line to indent the text
56 | paragraph and you're good to go.
57 |
58 |
59 | {title:Example}
60 |
61 | print {bf:bold} text
62 | . myprogram "print this text in bold", bold
63 |
64 | print {it:italic} text
65 | . myprogram "print this text in italic", i
66 |
67 | {title:Dynamic Graph}
68 |
69 | {c TLC}{hline 17}{c TRC} {c TLC}{hline 8}{c TRC} {c TLC}{hline 20}{c TRC}
70 | {c |} markdown source {c |}{hline 6}>{c |} mdddia {c |}{hline 5}-{c +}{hline 3}>{c |} processed markdown {c |}
71 | {c TLC}{hline 17}{c TRC} {c TLC}{hline 8}{c TRC} {c |} {c TLC}{hline 20}{c TRC}
72 | {c |} {c TLC}{hline 3}>{c |} image files {c |}
73 | {c TLC}{hline 18}{c TRC} {c TLC}{hline 20}{c TRC}
74 | {c |} diagram creation {c |}
75 | {c TLC}{hline 18}{c TRC}
76 | {c |} ditaa/dot/rdfdot {c |}
77 | {c TLC}{hline 18}{c TRC}
78 |
79 |
80 | {title: Source | SS df MS Number of obs = 74}
81 | Model | 139449474 1 139449474 Prob > F = 0.0000
82 |
83 | {title: Residual | 495615923 72 6883554.48 R-squared = 0.2196}
84 | Total | 635065396 73 8699525.97 Root MSE = 2623.7
85 |
86 | price | Coef. Std. Err. t P>|t| [95% Conf. Interval]
87 | mpg | -238.8943 53.07669 -4.50 0.000 -344.7008 -133.0879
88 |
89 | {title: _cons | 11253.06 1170.813 9.61 0.000 8919.088 13587.03}
90 |
91 |
92 |
93 | *cap prog drop markdoc
94 | markdoc test/helptest.ado, replace export(sthlp)
95 |
--------------------------------------------------------------------------------
/Examples/do/errors.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
88 |
89 |
90 |
91 |
Making the source code really reproducible
92 |
To make the do-file really reproducible, we have to make sure it does not access the data that is already loaded in Stata. Think about it, if you execute a do-file on a data that is already loaded and you have been working on it, can you ensure that re-executing the do-file creates the same results again? you might have done some changes outside of the do-file on the data - such as droping a record - which makes the results ireproducible.
93 |
The solution would be to run the do-file in a cleared workspace to ensure the do-file does not access the data that is already loaded. MarkDoc can take a do-file and execute the code in a cleared workspace and produce the dynamic document. This is a very different engine compared to rendering a smcl-log to a dynamic document.
94 |
If the do-file return an error, MarkDoc still create the dynamic document until the point the error occured. To run this do-file, first load the auto dataset in Stata. Then call markdoc to produce the dynamic document. You should get an error the no variables defined, which means your do-file does not load the data, although the data are loaded in your Stata.
95 |
. display "the next command will be an error"
96 |
the next command will be an error
97 |
98 |
. regress price mpg
99 |
no variables defined
100 | r(111);
101 |
102 | end of do-file
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/Torture_test/DOT/markdown_DOT.do:
--------------------------------------------------------------------------------
1 |
2 | // -----------------------------------------------------------------------------
3 | // Literate Visualization Notation
4 | // =============================================================================
5 | qui log using 000, replace smcl
6 | /***
7 | Dynamic Software Visualization
8 | =========================
9 |
10 |
11 | Writing software documentation and visualizing seletive information can
12 | boost active learning in students. It can also provide very useful information
13 | about structure of a software and encourages users to read the code and
14 | contribute to an open-source project. __MarkDoc package__ supports the
15 | ___DOT___ (graph description language), and it can produce HTML documents
16 | with graphs, written within the source code or data analysis.
17 |
18 | The graph can be written in different sections. However, MarkDoc has a
19 | separate syntax for beginning a new graph or continuing the previous graphs.
20 | to begin a new graph, use the regular syntax for wiriting documentation plus
21 | a double dollar sign and to continue using the current
22 | graph, use a single dollar sign. Here is an example:
23 | ***/
24 |
25 | /***$$
26 | digraph {
27 | Hello -> World;
28 | }
29 | ***/
30 |
31 | /***
32 | Continues figures
33 | -----------------
34 |
35 | It's much easier to write a detailed graph in different section and update
36 | it, when there is a change in that section. Writing a detailed graph at once
37 | and within a single section makes it _less interesting_ and makes it feel like
38 | _extra work_ when the job is already done. However if the graph is developed
39 | gradually, as the program is written, it's more encouraging. For example, the
40 | graph below is written in two separate sections.
41 | ***/
42 |
43 | /***$$
44 | graph ER {
45 | node [shape=box]; course; institute; student;
46 | node [shape=ellipse]; {node [label="name"] name0; name1; name2;}
47 | code; grade; number;
48 | node [shape=diamond,style=filled,color=lightgrey]; "C-I"; "S-C"; "S-I";
49 |
50 | name0 -- course;
51 | code -- course;
52 | course -- "C-I" [label="n",len=1.00];
53 | "C-I" -- institute [label="1",len=1.00];
54 | ***/
55 |
56 |
57 |
58 | /***$
59 | institute -- name1;
60 | institute -- "S-I" [label="1",len=1.00];
61 | "S-I" -- student [label="n",len=1.00];
62 | student -- grade;
63 | student -- name2;
64 | student -- number;
65 | student -- "S-C" [label="m",len=1.00];
66 | "S-C" -- course [label="n",len=1.00];
67 |
68 | label = "\n\nEntity Relation Diagram\ndrawn by NEATO";
69 | fontsize=20;
70 | }
71 | ***/
72 |
73 |
74 | /***
75 | Example 1
76 | ---------
77 | ***/
78 |
79 | /***$$
80 | digraph {
81 | subgraph cluster_0 {
82 | label="Subgraph A";
83 | a -> b;
84 | b -> c;
85 | c -> d;
86 | }
87 |
88 | subgraph cluster_1 {
89 | label="Subgraph B";
90 | a -> f;
91 | f -> c;
92 | }
93 | }
94 | ***/
95 |
96 |
97 | /***
98 | Example 2
99 | ---------
100 | ***/
101 |
102 | /***$$
103 | digraph {
104 | a -> b[label="0.2",weight="0.2"];
105 | a -> c[label="0.4",weight="0.4"];
106 | c -> b[label="0.6",weight="0.6"];
107 | c -> e[label="0.6",weight="0.6"];
108 | e -> e[label="0.1",weight="0.1"];
109 | e -> b[label="0.7",weight="0.7"];
110 | }
111 | ***/
112 |
113 |
114 |
115 |
116 |
117 |
118 | /***
119 | Example 3
120 | ---------
121 | ***/
122 | /***$$
123 | digraph G {
124 |
125 | subgraph cluster_0 {
126 | style=filled;
127 | color=lightgrey;
128 | node [style=filled,color=white];
129 | a0 -> a1 -> a2 -> a3;
130 | label = "process #1";
131 | }
132 |
133 | subgraph cluster_1 {
134 | node [style=filled];
135 | b0 -> b1 -> b2 -> b3;
136 | label = "process #2";
137 | color=blue
138 | }
139 | start -> a0;
140 | start -> b0;
141 | a1 -> b3;
142 | b2 -> a3;
143 | a3 -> a0;
144 | a3 -> end;
145 | b3 -> end;
146 |
147 | start [shape=Mdiamond];
148 | end [shape=Msquare];
149 | }
150 | ***/
151 |
152 |
153 |
154 | qui log c
155 | markdoc 000, replace exp(html)
156 |
--------------------------------------------------------------------------------
/Examples/Workshops/2018/dofiles/example.do:
--------------------------------------------------------------------------------
1 | // Comments will not be in the rendered document
2 |
3 | /*
4 | This is a comment
5 | */
6 |
7 | * Another comment
8 |
9 | // --------------------------------------------
10 |
11 | //OFF
12 |
13 | displa "this will be hidden"
14 |
15 | //ON
16 |
17 | /**/ display "Hellow World"
18 |
19 | /***/ display "hello world"
20 |
21 | /***
22 | Header
23 | ======
24 |
25 | sthing will appear
26 |
27 | Header 2
28 | --------
29 |
30 | ### Header 3
31 |
32 | #### Header 4
33 |
34 | ##### Header 5
35 |
36 | Part 2
37 | =======
38 |
39 |
40 | This is a text paragraph. Text can be *italic* or
41 | _italic_. Also, it can be **Bold** or __Bold__.
42 |
43 | > "the text paragraph can be indented for - typically -quoting "
44 |
45 | - This is item 1
46 | - Item 2
47 | - item 3
48 | * This is another item
49 | - quite file I hope
50 | - sublist item 1
51 | - sublist 2
52 | - subsublist 1
53 | - item
54 | 1. sth
55 | 2. sth
56 | - continue with sublist
57 | - continue with the list
58 |
59 |
60 | Numbered list
61 | ==============
62 |
63 | 1. numbered item 1
64 | 2. item 2
65 | 1. subitem 1
66 | 2. subitem 2
67 | 2. subsub item
68 | 2. sth
69 | 3. back to item
70 |
71 | Using the "---" sign will add a line in the document
72 |
73 | ---
74 |
75 | Breaking the line
76 | -----------------
77 |
78 | Add 2 or more spaces at the end of the line to break it without
79 | starting
80 | a new
81 | paragraph
82 |
83 |
84 | ---
85 |
86 |
87 | Adding links
88 | -------------
89 |
90 | This is a link to MarkDoc's GitHub Manual
91 |
92 |
93 | You can also change the __hypertext__ e.g.
94 | [MarDoc's Manual](https://github.com/haghish/MarkDoc/wiki)
95 |
96 | ---
97 |
98 | ***/
99 |
100 | sysuse auto, clear //load auto dataset
101 |
102 | summarize
103 |
104 | /***
105 | ---
106 | ***/
107 |
108 | histogram price
109 | graph export ./price_hist.png, replace width(300)
110 |
111 | /***
112 | Including a figure
113 | ------------------
114 |
115 | Next, I include the histogram of the Price variable using
116 | the `histogram` command and the `price` variable.
117 |
118 | ---
119 |
120 | 
121 |
122 | ***/
123 |
124 |
125 | // reloading the same image using `img` command:
126 | img using "./price_hist.png", title("using the img command to include exported figure")
127 |
128 |
129 | histogram mpg
130 |
131 | img, title("Figure 2. Histogram of the `mpg` variable")
132 |
133 |
134 | /***
135 |
136 | ---
137 |
138 | Writing dynamic text
139 | --------------------
140 |
141 | use the `txt` command to interpret values of macros and scalars:
142 | ***/
143 |
144 | summarize price
145 | return list
146 |
147 | txt "The number of subject is " r(N) " subjects in the darta set. "
148 |
149 |
150 | /***
151 |
152 | ---
153 |
154 | creating table
155 | ---------------
156 |
157 |
158 | | __Optopns__ | __Discription__ |
159 | |-------------|------------------------------------------------------------------|
160 | | markup(str) | specifies the markup language that is used for documentation |
161 | | title(str) | displays the table description |
162 | | width(int) | specifies the width of the table in HTML and LaTeX |
163 | | height(int) | specifies the height of the table in HTML and LaTeX |
164 | | center | aligns the table to the center of the document in HTML and LaTeX |
165 | | left | aligns the table to the left of the document |
166 |
167 | ---
168 |
169 | size material color
170 | ---- ------------ ------------
171 | 9 leather brown
172 | 10 hemp canvas natural
173 | 11 glass transparent
174 |
175 |
176 | Mathematical notations
177 | ======================
178 |
179 | You can use markdoc to:
180 |
181 | 1. write inline notations (i.e. in the text paragraphs)
182 | 2. on a separate line
183 |
184 | For example, $\sum$ will appear inline whereas $$\sum$$ will be on another line.
185 | ***/
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
--------------------------------------------------------------------------------
/Torture_test/sthlp/example.ado:
--------------------------------------------------------------------------------
1 | /*** DO NOT EDIT THIS LINE -----------------------------------------------------
2 |
3 | Version: 1.0.0
4 |
5 |
6 | Intro Description
7 | =================
8 |
9 | myprogram -- A new module for to print text. This description can include
10 | multiple lines, but not several paragraphs. You may write the title section
11 | in multiple lines. {help MarkDoc} will connect the lines to create only a
12 | single paragraph. If you'd like to describe the package more, create a
13 | description section below this header.
14 |
15 | Author(s) section
16 | =================
17 |
18 | E. F. Haghish
19 | University of Freiburg
20 | haghish@imbi.uni-freiburg.de
21 | {browse "http://www.haghish.com/markdoc"}
22 |
23 | Syntax
24 | =================
25 |
26 | {opt myprogram} [{it:anything}] [, {opt b:old} {opt i:talic}]
27 |
28 | {synoptset 20 tabbed}{...}
29 | {synopthdr}
30 | {synoptline}
31 | {synopt :{opt b:old}}prints bold text{p_end}
32 | {synopt :{opt i:talic}}prints italic text{p_end}
33 | {synoptline}
34 | ----------------------------------------------------- DO NOT EDIT THIS LINE ***/
35 |
36 | * Note: If you like to leave the "Intro Description" or "Author(s) section
37 | * empty, erase the text but KEEP THE HEADINGS
38 |
39 |
40 | cap prog drop myprogram
41 | program myprogram
42 | syntax [anything] [, Bold Italic]
43 | if missing("`bold'") & missing("`italic'") {
44 | display as txt `anything'
45 | }
46 | else if !missing("`bold'") & missing("`italic'") {
47 | local anything : display `anything'
48 | display as txt "{bf:`anything'}"
49 | }
50 | else if missing("`bold'") & !missing("`italic'") {
51 | local anything : display `anything'
52 | display as txt "{it:`anything'}"
53 | }
54 | else {
55 | local anything : display `anything'
56 | display "{bf:{it:`anything'}}"
57 | }
58 | end
59 |
60 |
61 | /***
62 |
63 |
64 | : Typically, the text paragraphs in Stata help files begin with an indention,
65 | which makes the help file easier to read (and that's important). To do so,
66 | place a {bf:{c -(}p 4 4 2{c )-}} directive above the line to indent the text
67 | paragraph and you're good to go.
68 |
69 | : this is a text paragraph that is processing __Markdown__, _italic text_ or
70 | ___underscored text___. The only thing left is the link! but how far can this
71 | __text styling go__? I mean how far does the
72 | rabit whole go? do you have any idea?
73 |
74 |
75 | - - -
76 |
77 | : this is a text paragraph that is processing __Markdown__, _italic text_ or
78 | ___underscored text___. The only thing left is the link! but how far can this
79 | __text styling go__? I mean how far does the
80 | rabit whole go? do you have any idea?
81 |
82 |
83 | > this is a text paragraph that is processing __Markdown__, _italic text_ or
84 | ___underscored text___. The only thing left is the link! but how far can this
85 | __text styling go__? I mean how far does the
86 | rabit whole go? do you have any idea?
87 |
88 |
89 | Another heading
90 | ----------------------
91 |
92 | {p 4 4 2}
93 | Typically, the text paragraphs in Stata help files begin with an indention,
94 | which makes the help file easier to read (and that's important). To do so,
95 | place a {bf:{c -(}p 4 4 2{c )-}} directive above the line to indent the text
96 | paragraph and you're good to go.
97 |
98 | ***/
99 |
100 | /***
101 | Example
102 | =================
103 |
104 | print {bf:bold} text
105 | . myprogram "print this text in bold", bold
106 |
107 | print {it:italic} text
108 | . myprogram "print this text in italic", i
109 | ***/
110 |
111 | /***
112 | Dynamic Graph
113 | =============
114 |
115 | +-----------------+ +--------+ +--------------------+
116 | | markdown source |------>| mdddia |---------->| processed markdown |
117 | +-----------------+ +--------+ | +--------------------+
118 | | +--->| image files |
119 | +------------------+ +--------------------+
120 | | diagram creation |
121 | +------------------+
122 | | ditaa/dot/rdfdot |
123 | +------------------+
124 |
125 | ***/
126 |
127 | *cap prog drop markdoc
128 |
129 |
--------------------------------------------------------------------------------
/Torture_test/do/example.do:
--------------------------------------------------------------------------------
1 | /*** DO NOT EDIT THIS LINE -----------------------------------------------------
2 |
3 | Version: 0.0.0
4 |
5 |
6 | Intro Description
7 | =================
8 |
9 | packagename -- A new module for ...
10 |
11 |
12 | Author(s) section
13 | =================
14 |
15 | Author name ...
16 | Author affiliation ...
17 | to add more authors, leave an empty line between authors' information
18 |
19 | Second author ...
20 | For more information visit {browse "http://www.haghish.com/markdoc":MarkDoc homepage}
21 |
22 |
23 | Syntax
24 | =================
25 |
26 | {opt exam:ple} {depvar} [{indepvars}] {ifin} using
27 | [{it:{help filename:filename}}]
28 | [{cmd:,} {it:options}]
29 |
30 | {synoptset 20 tabbed}{...}
31 | {synopthdr}
32 | {synoptline}
33 | {synopt :{opt rep:lace}}replace this example{p_end}
34 | {synopt :{opt app:end}}work further on this help file{p_end}
35 | {synopt :{opt addmore}}you can add more description for the options; Moreover,
36 | the text you write can be placed in multiple lines {p_end}
37 | {synopt :{opt learn:smcl}}you won't make a loss learning
38 | {help smcl:SMCL Language} {p_end}
39 | {synoptline}
40 | ----------------------------------------------------- DO NOT EDIT THIS LINE ***/
41 |
42 | * Note: If you like to leave the "Intro Description" or "Author(s) section
43 | * empty, erase the text but KEEP THE HEADINGS
44 |
45 |
46 |
47 |
48 |
49 | /***
50 |
51 | \section{Reading statistical packages}
52 |
53 | :Literate programming was adopted by statisticians for documenting the process of data analysis and generating dynamic analysis reports \cite{ Literate_programming_using_noweb, 1994_Literate_programming_simplified, Literate_Statistical_Programming.Concepts_and_Tools} and several literate programming packages have been developed particularly for statistical languages to meet the special features required for analysis reports \cite{weaver, markdoc, xie2013knitr, xieknit, leisch2002sweave, allaire2015rmarkdown, statweave}.
54 |
55 | >While statisticians strongly support literate programming for data analysis, when it comes to programming statistical packages, the best they have come up with is documenting individual functions and objects using literate programming packages such as Roxygen2 \cite{roxygen2:In-source_documentation_for_R} in R or MarkDoc \cite{markdoc} in Stata. However, as the number of script files and the structural complexity of the package (nested files or functions) increase, the object documentation will provide minor information about the overall structure and logic of the package.
56 |
57 | Any R package includes a number of R script files and each may include one or more functions. Furthermore, each of these functions may call other functions written in different script files within the package as well. Thus, an R package with a few files and functions, may have a very complex nested structure. Furthermore, R packages may include script files written in other programming languages, such as C or C++ which further increases the complexity of the package.
58 |
59 | My argument is that open source programming languages such as R that do not require header files, should be carefully documented at both micro-level and macro-level to improve the readability of the package. The micro-level documentation is already advocated by literate programming packages. However, macro-level documentation -- inferring on the overall architecture of the package and function dependency -- is surprisingly ignored. To treat R packages truly as work of literature that should be read by humans and not just the compiler, as Knuth proposed, we should bear in mind that instead of instructing a ``computer what to do'', we shall ``concentrate rather on explaining to human beings what we want a computer to do'' \cite{knuth1984literate, knuth1992book}.
60 |
61 | Yet, there has been no software for macro-level documentation of R packages. In the current article, I introduce CodeMap, an application written for Macintosh operating system, that discovers the file and function dependency tree of an R package, and visualize them in an interactively.
62 |
63 | ***/
64 |
65 |
66 | markdoc example.do, export(sthlp) markup() replace linesize(120) ///
67 | printer("/usr/texbin/pdflatex")
68 |
69 | /***
70 | Example
71 | =================
72 |
73 | explain what it does
74 | . example command
75 |
76 | second explanation
77 | . example command
78 | ***/
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------