rl_lang/docs/entries/stdlib/io/
mod.rs1use crate::docs::entry::{FnEntry, StdEntry};
2
3pub static IO: StdEntry = StdEntry {
4 name: "io",
5 description: "functions for input and output",
6 functions: FUNCTIONS,
7 since: None,
8 unstable: false,
9};
10
11static FUNCTIONS: &[&FnEntry] = &[
12 &READ,
13 &READ_PROMPT,
14 &READ_INT,
15 &READ_INT_PROMPT,
16 &READ_FLOAT,
17 &READ_FLOAT_PROMPT,
18 &APPEND_FILE,
19 &DELETE_FILE,
20 &READ_FILE,
21 &READ_LINES,
22 &WRITE_FILE,
23 &PRINT,
24 &PRINTLN,
25 &EPRINT,
26];
27
28static READ: FnEntry = FnEntry {
29 signature: "read()",
30 description: "read a line from stdin",
31 example: "get std::io::read\n\ndec str name = read()",
32 expected_output: None,
33 returns: "",
34 errors: None,
35 see_also: &[],
36 since: None,
37};
38
39static READ_PROMPT: FnEntry = FnEntry {
40 signature: "read(prompt)",
41 description: "prints prompt and reads a line from stdin",
42 example: "get std::io::read\n\ndec str name = read(\"enter your name: \")",
43 expected_output: None,
44 returns: "",
45 errors: None,
46 see_also: &[],
47 since: None,
48};
49
50static READ_INT: FnEntry = FnEntry {
51 signature: "read_int()",
52 description: "read a line from stdin then parses to integer",
53 example: "get std::io::read_int\n\ndec int age = read()",
54 expected_output: None,
55 returns: "",
56 errors: None,
57 see_also: &[],
58 since: None,
59};
60
61static READ_INT_PROMPT: FnEntry = FnEntry {
62 signature: "read_int(prompt)",
63 description: "prints prompt and reads a line from stdin then parses to integer",
64 example: "get std::io::read_int\n\ndec int age = read_float(\"enter your age: \")",
65 expected_output: None,
66 returns: "",
67 errors: None,
68 see_also: &[],
69 since: None,
70};
71
72static READ_FLOAT: FnEntry = FnEntry {
73 signature: "read_float()",
74 description: "read a line from stdin then parses to float",
75 example: "get std::io::read_float\n\ndec float pi = read_float()",
76 expected_output: None,
77 returns: "",
78 errors: None,
79 see_also: &[],
80 since: None,
81};
82
83static READ_FLOAT_PROMPT: FnEntry = FnEntry {
84 signature: "read_float(prompt)",
85 description: "prints prompt and reads a line from stdin then parses to float",
86 example: "get std::io::read_float\n\ndec float pi = read_float(\"enter your pi: \")",
87 expected_output: None,
88 returns: "",
89 errors: None,
90 see_also: &[],
91 since: None,
92};
93
94static APPEND_FILE: FnEntry = FnEntry {
95 signature: "append_file(path, content)",
96 description: "appends content to a file creating it if it does not exist",
97 example: "get std::io::append_file\n\nappend_file(\"info.txt\", \"name: Mohamed\")",
98 expected_output: None,
99 returns: "",
100 errors: None,
101 see_also: &[],
102 since: None,
103};
104
105static DELETE_FILE: FnEntry = FnEntry {
106 signature: "delete_file(path)",
107 description: "deletes a file at the given path",
108 example: "get std::io::delete_file\n\ndelete_file(\"info.txt\")",
109 expected_output: None,
110 returns: "",
111 errors: None,
112 see_also: &[],
113 since: None,
114};
115
116static READ_FILE: FnEntry = FnEntry {
117 signature: "read_file(path)",
118 description: "reads the entire contents of a file as a string",
119 example: "get std::io::read_file\n\ndec string data = read_file(\"backup_info.txt\")",
120 expected_output: None,
121 returns: "",
122 errors: None,
123 see_also: &[],
124 since: None,
125};
126
127static READ_LINES: FnEntry = FnEntry {
128 signature: "read_lines(path)",
129 description: "reads a file and returns its lines as an array of strings",
130 example: "get std::io::read_lines\n\ndec arr[string] data = read_lines(\"index.html\")",
131 expected_output: None,
132 returns: "",
133 errors: None,
134 see_also: &[],
135 since: None,
136};
137
138static WRITE_FILE: FnEntry = FnEntry {
139 signature: "write_file(path, contents)",
140 description: "writes content to a file overwriting it if it already exists",
141 example: "get std::io::write_file\n\nwrite_file(\"index.html\", \"<p>hello \\\"Mohamed\\\"</p>\")",
142 expected_output: None,
143 returns: "",
144 errors: None,
145 see_also: &[],
146 since: None,
147};
148
149static PRINT: FnEntry = FnEntry {
150 signature: "print(x)",
151 description: "print without newline",
152 example: "get std::io::print\n\nprint(\"hello\")",
153 expected_output: None,
154 returns: "",
155 errors: None,
156 see_also: &[],
157 since: None,
158};
159
160static PRINTLN: FnEntry = FnEntry {
161 signature: "println(x)",
162 description: "print with newline",
163 example: "get std::io:println\n\nprintln(\"hello\")",
164 expected_output: None,
165 returns: "",
166 errors: None,
167 see_also: &[],
168 since: None,
169};
170
171static EPRINT: FnEntry = FnEntry {
172 signature: "eprint(string)",
173 description: "halts evaluation with an error containing the given message",
174 example: "get std::io::eprint\n\neprint(\"something went wrong\") // x error: something went wrong",
175 expected_output: None,
176 returns: "",
177 errors: None,
178 see_also: &[],
179 since: None,
180};