-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlibd3.ado
73 lines (45 loc) · 1.58 KB
/
libd3.ado
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Drop program if already loaded in memory
cap prog drop libd3
// Define program to automate compiling mata classes for D3js wrappers
prog def libd3, rclass
// Version of Stata to use
version 12
// Define syntax structure for program
syntax [, DIsplay MLib MOSave dir(passthru) REPlace size(integer 2048) ///
QUIetly noPATH ]
// Clear any existing class from mata
mata: mata clear
// Build a class list macro to store the names of the mata classes
loc classlist ""
// Check for path option
if `"`path'"' != "nopath" {
// Set Directory for locating Mata source
loc location `c(sysdir_plus)'d/
} // End IF Block for nopath option
// Drop class if exists in mata already
cap mata: mata drop d3()
// Compile the mega d3 class
`quietly' do `"`location'd3.mata"'
// Check for MoSave option
if `"`mosave'"' != "" & `"`mlib'"' == "" {
// Save the mata objects
mata: mata mosave d3, `dir' complete `replace'
} // End IF Block for mata mo save
// Check for MLib option
if `"`mlib'"' != "" {
// Create the library
mata: mata mlib create libd3, `dir' size(`size') `replace'
// Add the first class to the library
mata: mata mlib add libd3 d3(), `dir' complete
// Index the mata classes/functions
mata: mata mlib index
} // End IF Block to build custom d3 library for user
// If display option is turned on
if "`display'" != "" {
// Print message to screen
di as res "Successfully compiled libd3" _n _continue
// Describe the classes/methods
mata: mata d d3()
} // End IF Block for display option
// End of program
end