Compare commits
2 Commits
7acab5d229
...
a87ceb2f19
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a87ceb2f19 | ||
|
|
e6cf7aa636 |
1082
doc/Doc.html
Normal file
1082
doc/Doc.html
Normal file
File diff suppressed because it is too large
Load Diff
22
doc/readme.txt
Normal file
22
doc/readme.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
to convert Doc.md to Doc.html use https://markdowntohtml.com/ with custom ccs style
|
||||
|
||||
body {
|
||||
color: black;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table, th, td {
|
||||
border: 1px solid;
|
||||
}
|
||||
th {
|
||||
text-align: left;
|
||||
}
|
||||
td {
|
||||
height: 50px;
|
||||
vertical-align: top;
|
||||
}
|
||||
code{
|
||||
background: #0003;
|
||||
color: #a31515;
|
||||
}
|
||||
9
ml.cpp
9
ml.cpp
@@ -2196,9 +2196,6 @@ MlValue usql(std::vector<MlValue> args, MlEnvironment &env) {
|
||||
|
||||
} // namespace builtin
|
||||
|
||||
void load_std_lib(MlEnvironment &env) {
|
||||
run(STDLIB_LOADER, env);
|
||||
}
|
||||
|
||||
// Does this environment, or its parent environment, have a variable?
|
||||
bool MlEnvironment::has(const std::string &name) const {
|
||||
@@ -2440,6 +2437,12 @@ std::vector<std::string> getCmdOption(char *argv[], int argc, const std::string
|
||||
return tokens;
|
||||
}
|
||||
|
||||
|
||||
void load_std_lib(MlEnvironment &env) {
|
||||
run(STDLIB_LOADER, env);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
MlEnvironment env;
|
||||
std::vector<MlValue> args;
|
||||
|
||||
@@ -43,6 +43,12 @@
|
||||
nil
|
||||
))
|
||||
|
||||
(defn doc::print-entry (entry)
|
||||
(do (def call (doc::strip-backticks (second entry)))
|
||||
(def desc (doc::strip-backticks (third entry)))
|
||||
(print (term-red (first entry)) "-" (term-green (doc::strip-backticks (second entry))) "-" (third entry))
|
||||
))
|
||||
|
||||
(defn doc::man (what)
|
||||
(do (def man (filter (lambda (x) (= (first x) what)) doc::doc_entries))
|
||||
(if man
|
||||
@@ -75,29 +81,54 @@
|
||||
|
||||
(def sorted (quick-sort-by scores (lambda (a b) (< (first a) (first b)))))
|
||||
(for e (take sorted 10)
|
||||
(def entry (second e))
|
||||
(def call (doc::strip-backticks (second entry)))
|
||||
(def desc (doc::strip-backticks (third entry)))
|
||||
(print (term-red (first entry)) "-" (term-green (doc::strip-backticks (second entry))) "-" (third entry))
|
||||
)
|
||||
(doc::print-entry (second e))))
|
||||
|
||||
(if (> (len sorted) 10) (print "..."))
|
||||
))
|
||||
|
||||
(defn doc::section (what)
|
||||
(do
|
||||
(def entries '())
|
||||
(for entry doc::doc_entries
|
||||
; ("throw-exception" "`(throw-exception exp_desc)`" "Throws an exception with exp_desc describing what happened " "" "Exceptions"
|
||||
; section matches
|
||||
(if (= (string-downcase (fifth entry)) (string-downcase what))
|
||||
(set! entries (push entries entry)))
|
||||
)
|
||||
|
||||
(for e (quick-sort-by entries (lambda (a b) (> (string-cmp (first a) (first b)) 0)))
|
||||
(doc::print-entry e))
|
||||
))
|
||||
|
||||
(defn doc::all ()
|
||||
(for e (quick-sort-by doc::doc_entries (lambda (a b) (> (string-cmp (first a) (first b)) 0)))
|
||||
(doc::print-entry e))
|
||||
)
|
||||
|
||||
(defn doc::appropos (which)
|
||||
(doc::look which))
|
||||
|
||||
(defn doc::lookup (which)
|
||||
(doc::look which))
|
||||
|
||||
;(defn doc::section (which)
|
||||
; (print (term-red "implement me!")))
|
||||
(defn doc::doc ()
|
||||
(do
|
||||
(print "Usage:")
|
||||
(print "\t(doc::doc) - shows this help")
|
||||
(print "\t(doc::man func) - func must be a string, ie (doc::man \"for\")")
|
||||
(print "\t(doc::look str) - str must be a string, ie (doc::look \"length\")")
|
||||
(print "\t(doc::lookup) - alias for doc::look")
|
||||
(print "\t(doc::appropos) - alias for doc::look")
|
||||
(print "\t(doc::all) - show short info about all functions")
|
||||
(print "\t(doc::section sec) - show help for section, sec is string one of:")
|
||||
(print "\t\t\t\t\"List manipulation\" \"Language\" \"System\"")
|
||||
(print "\t\t\t\t\"String manipulation\" \"Date and time\" \"IO\" \"Regex\"")
|
||||
(print "\t\t\t\t\"Type casting\" \"Threading\" \"Exceptions\"")
|
||||
))
|
||||
|
||||
|
||||
(def doc::doc_entries '()) ; must be here
|
||||
|
||||
; read doc into memory
|
||||
(doc::read-doc-file "/usr/local/var/mlisp/Doc.md")
|
||||
|
||||
;;example
|
||||
; (doc::man "first")
|
||||
; (doc::look "string pad")
|
||||
; (doc::look "list flat")
|
||||
|
||||
Reference in New Issue
Block a user