io.stdin, io.stdout, io.stderr added to docs (there's no section for these in the manual)

This commit is contained in:
XeroOl 2024-05-15 23:01:05 -05:00
parent 1a21ee623d
commit fd40c31cd9
5 changed files with 46 additions and 1 deletions

View File

@ -29,9 +29,12 @@
(table.insert fields section))) (table.insert fields section)))
(when header (loop header)))) (when header (loop header))))
(fn make-title [name]
(.. "<hr><h3><a name=\"pdf-" name "\"><code>" name "</code></a></h3>\n"))
;; Artificially insert the `arg` docs. ;; Artificially insert the `arg` docs.
;; This isn't present in the "Basic Functions" part of the manual, but is still useful to be included in the docs. ;; This isn't present in the "Basic Functions" part of the manual, but is still useful to be included in the docs.
(let [arg-signature "<hr><h3><a name=\"pdf-arg\"><code>arg</code></a></h3>\n" (let [arg-signature (make-title :arg)
arg-description (-> html arg-description (-> html
;; The goal here is to extract the smallest string which: ;; The goal here is to extract the smallest string which:
;; 1) contains the string "global table called <code>arg</code>" ;; 1) contains the string "global table called <code>arg</code>"
@ -46,6 +49,9 @@
(: :match "(.-)>p<\n") (: :match "(.-)>p<\n")
(: :reverse))] (: :reverse))]
(table.insert fields (.. arg-signature arg-description))) (table.insert fields (.. arg-signature arg-description)))
(table.insert fields (.. (make-title "io.stdin") "stdin file"))
(table.insert fields (.. (make-title "io.stdout") "stdout file"))
(table.insert fields (.. (make-title "io.stderr") "stderr file"))
(loop (stdlib:find "<hr><h3>.-\n")) (loop (stdlib:find "<hr><h3>.-\n"))
(values modules fields last-update))) (values modules fields last-update)))
@ -205,6 +211,9 @@
(view (list (sym :local) (sym :docs) docs)) (view (list (sym :local) (sym :docs) docs))
"\n" "\n"
"(set docs._G.fields docs)\n" "(set docs._G.fields docs)\n"
"(set docs.io.fields.stdin.fields docs.io.fields)\n"
"(set docs.io.fields.stdout.fields docs.io.fields)\n"
"(set docs.io.fields.stderr.fields docs.io.fields)\n"
"docs\n")) "docs\n"))
(print (.. "Emitted docs for lua" version))))) (print (.. "Emitted docs for lua" version)))))

View File

@ -418,6 +418,12 @@ on all platforms."}}
:read {:binding "io.read" :read {:binding "io.read"
:metadata {:fnl/arglist ["..."] :metadata {:fnl/arglist ["..."]
:fnl/docstring "Equivalent to `io.input():read`."}} :fnl/docstring "Equivalent to `io.input():read`."}}
:stderr {:binding "io.stderr"
:metadata {:fnl/docstring "stderr file"}}
:stdin {:binding "io.stdin"
:metadata {:fnl/docstring "stdin file"}}
:stdout {:binding "io.stdout"
:metadata {:fnl/docstring "stdout file"}}
:tmpfile {:binding "io.tmpfile" :tmpfile {:binding "io.tmpfile"
:metadata {:fnl/arglist {} :metadata {:fnl/arglist {}
:fnl/docstring "Returns a handle for a temporary file. :fnl/docstring "Returns a handle for a temporary file.
@ -1401,4 +1407,7 @@ after this first result.
In case of any error, In case of any error,
`xpcall` returns **false** plus the result from `err`."}}}) `xpcall` returns **false** plus the result from `err`."}}})
(set docs._G.fields docs) (set docs._G.fields docs)
(set docs.io.fields.stdin.fields docs.io.fields)
(set docs.io.fields.stdout.fields docs.io.fields)
(set docs.io.fields.stderr.fields docs.io.fields)
docs docs

View File

@ -577,6 +577,12 @@ or to write data to this program
:read {:binding "io.read" :read {:binding "io.read"
:metadata {:fnl/arglist ["..."] :metadata {:fnl/arglist ["..."]
:fnl/docstring "Equivalent to `io.input():read(...)`."}} :fnl/docstring "Equivalent to `io.input():read(...)`."}}
:stderr {:binding "io.stderr"
:metadata {:fnl/docstring "stderr file"}}
:stdin {:binding "io.stdin"
:metadata {:fnl/docstring "stdin file"}}
:stdout {:binding "io.stdout"
:metadata {:fnl/docstring "stdout file"}}
:tmpfile {:binding "io.tmpfile" :tmpfile {:binding "io.tmpfile"
:metadata {:fnl/arglist {} :metadata {:fnl/arglist {}
:fnl/docstring "Returns a handle for a temporary file. :fnl/docstring "Returns a handle for a temporary file.
@ -1656,4 +1662,7 @@ and `\"userdata\"`."}}
:fnl/docstring "This function is similar to `pcall`, :fnl/docstring "This function is similar to `pcall`,
except that it sets a new message handler `msgh`."}}}) except that it sets a new message handler `msgh`."}}})
(set docs._G.fields docs) (set docs._G.fields docs)
(set docs.io.fields.stdin.fields docs.io.fields)
(set docs.io.fields.stdout.fields docs.io.fields)
(set docs.io.fields.stderr.fields docs.io.fields)
docs docs

View File

@ -464,6 +464,12 @@ or to write data to this program
:read {:binding "io.read" :read {:binding "io.read"
:metadata {:fnl/arglist ["..."] :metadata {:fnl/arglist ["..."]
:fnl/docstring "Equivalent to `io.input():read(...)`."}} :fnl/docstring "Equivalent to `io.input():read(...)`."}}
:stderr {:binding "io.stderr"
:metadata {:fnl/docstring "stderr file"}}
:stdin {:binding "io.stdin"
:metadata {:fnl/docstring "stdin file"}}
:stdout {:binding "io.stdout"
:metadata {:fnl/docstring "stdout file"}}
:tmpfile {:binding "io.tmpfile" :tmpfile {:binding "io.tmpfile"
:metadata {:fnl/arglist {} :metadata {:fnl/arglist {}
:fnl/docstring "In case of success, :fnl/docstring "In case of success,
@ -1687,4 +1693,7 @@ negative indices count from the end of the string."}}
:fnl/docstring "This function is similar to `pcall`, :fnl/docstring "This function is similar to `pcall`,
except that it sets a new message handler `msgh`."}}}) except that it sets a new message handler `msgh`."}}})
(set docs._G.fields docs) (set docs._G.fields docs)
(set docs.io.fields.stdin.fields docs.io.fields)
(set docs.io.fields.stdout.fields docs.io.fields)
(set docs.io.fields.stderr.fields docs.io.fields)
docs docs

View File

@ -508,6 +508,12 @@ or to write data to this program
:read {:binding "io.read" :read {:binding "io.read"
:metadata {:fnl/arglist ["..."] :metadata {:fnl/arglist ["..."]
:fnl/docstring "Equivalent to `io.input():read(...)`."}} :fnl/docstring "Equivalent to `io.input():read(...)`."}}
:stderr {:binding "io.stderr"
:metadata {:fnl/docstring "stderr file"}}
:stdin {:binding "io.stdin"
:metadata {:fnl/docstring "stdin file"}}
:stdout {:binding "io.stdout"
:metadata {:fnl/docstring "stdout file"}}
:tmpfile {:binding "io.tmpfile" :tmpfile {:binding "io.tmpfile"
:metadata {:fnl/arglist {} :metadata {:fnl/arglist {}
:fnl/docstring "In case of success, :fnl/docstring "In case of success,
@ -1868,4 +1874,7 @@ it ignores unknown control messages."}}
:fnl/docstring "This function is similar to `pcall`, :fnl/docstring "This function is similar to `pcall`,
except that it sets a new message handler `msgh`."}}}) except that it sets a new message handler `msgh`."}}})
(set docs._G.fields docs) (set docs._G.fields docs)
(set docs.io.fields.stdin.fields docs.io.fields)
(set docs.io.fields.stdout.fields docs.io.fields)
(set docs.io.fields.stderr.fields docs.io.fields)
docs docs