Skip to content

Commit caf0256

Browse files
committed
docs
1 parent 78e3b55 commit caf0256

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

7Sharp/Intrerpreter/Interpreter.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.IO;
99
using System.Linq;
1010
using System.Text;
11-
using System.Text.RegularExpressions;
1211
using System.Threading.Tasks;
1312
using Techcraft7_DLL_Pack.Text;
1413
// Alias for List<Token<TokenType>> because its a pain to type

7Sharp/Intrerpreter/SysLibraries/LibIO.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using _7Sharp.Manual;
2+
using System;
23
using System.Collections.Generic;
34
using System.IO;
45
using System.Linq;
@@ -59,6 +60,7 @@ public override void Import(ref InterpreterState state)
5960

6061
private static void WriteText(Stream s, string text) => WriteText(s, text, "utf8");
6162

63+
[ManualDocs("writeText", "{\"title\":\"writeText(s, txt, enc = \\\"utf8\\\")\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"writeText(<stream>, <text>);\nOR\nwriteText(<stream>, <text>, <encoding>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Write \"},{\"text\":\"txt\",\"color\":\"Green\"},{\"text\":\" to stream \"},{\"text\":\"s\",\"color\":\"Green\"},{\"text\":\" using encoding \"},{\"text\":\"enc\",\"color\":\"Green\"},{\"text\":\". Defaults to \"},{\"text\":\"utf8\",\"color\":\"Cyan\"}]}]}")]
6264
private static void WriteText(Stream stream, string text, string encoding)
6365
{
6466
if (stream.CanWrite)
@@ -91,6 +93,7 @@ private static void WriteText(Stream stream, string text, string encoding)
9193
}
9294
}
9395

96+
[ManualDocs("readText", "{\"title\":\"readText(s, count, enc = \\\"utf8\\\")\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"readText(<stream>, <text>);\nOR\nreadText(<stream>, <text>, <encoding>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Read \"},{\"text\":\"count\",\"color\":\"Green\"},{\"text\":\" characters from stream \"},{\"text\":\"s\",\"color\":\"Green\"},{\"text\":\" using encoding \"},{\"text\":\"enc\",\"color\":\"Green\"},{\"text\":\". \"},{\"text\":\"enc\",\"color\":\"Green\"},{\"text\":\" defaults to \"},{\"text\":\"utf8\",\"color\":\"Cyan\"}]}]}")]
9497
private static string ReadText(Stream s, int count) => ReadText(s, count, "utf8");
9598

9699
private static string ReadText(Stream s, int count, string encoding)
@@ -127,6 +130,7 @@ private static string ReadText(Stream s, int count, string encoding)
127130
}
128131
}
129132

133+
[ManualDocs("close", "{\"title\":\"close(s)\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"close(<stream>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Close stream \"},{\"text\":\"s\",\"color\":\"Green\"},{\"text\":\". \"},{\"text\":\"Not doing this could cause a memory leak!\",\"color\":\"Red\"}]}]}")]
130134
private static void Close(Stream s)
131135
{
132136
try
@@ -139,6 +143,7 @@ private static void Close(Stream s)
139143
}
140144
}
141145

146+
[ManualDocs("readFile", "{\"title\":\"readFile(path)\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"readFile(<path>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Get a read stream to file at \"},{\"text\":\"path\",\"color\":\"Green\"},{\"text\":\". See the following for more info: \"},{\"text\":\"readText readLine readByte\",\"color\":\"Yellow\"}]}]}")]
142147
private static Stream ReadFile(string path)
143148
{
144149
if (!File.Exists(path))
@@ -211,6 +216,7 @@ private static void WriteByte(Stream stream, int v)
211216
}
212217
}
213218

219+
[ManualDocs("readLine", "{\"title\":\"readLine(s, enc = \\\"utf8\\\")\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"readLine(<stream>);\nOR\nreadLine(<stream>, <encoding>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Read \"},{\"text\":\"count\",\"color\":\"Green\"},{\"text\":\" one line of text from stream \"},{\"text\":\"s\",\"color\":\"Green\"},{\"text\":\" using encoding \"},{\"text\":\"enc\",\"color\":\"Green\"},{\"text\":\". \"},{\"text\":\"enc\",\"color\":\"Green\"},{\"text\":\" defaults to \"},{\"text\":\"utf8\",\"color\":\"Cyan\"}]}]}")]
214220
private static string ReadLine(Stream stream) => ReadLine(stream, "utf8");
215221

216222
private static string ReadLine(Stream stream, string encoding)
@@ -267,7 +273,8 @@ private static string ReadLine(Stream stream, string encoding)
267273
}
268274

269275
private static void WriteLine(Stream stream, string line) => WriteLine(stream, line, "utf8");
270-
276+
277+
[ManualDocs("writeLine", "{\"title\":\"writeText(s, txt, enc = \\\"utf8\\\")\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"writeText(<stream>, <text>);\nOR\nwriteText(<stream>, <text>, <encoding>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Write \"},{\"text\":\"txt\",\"color\":\"Green\"},{\"text\":\" to stream \"},{\"text\":\"s\",\"color\":\"Green\"},{\"text\":\" using encoding \"},{\"text\":\"enc\",\"color\":\"Green\"},{\"text\":\", followed by a new line. \"},{\"text\":\"enc\",\"color\":\"Green\"},{\"text\":\" defaults to \"},{\"text\":\"utf8\",\"color\":\"Cyan\"}]}]}")]
271278
private static void WriteLine(Stream stream, string line, string encoding) => WriteText(stream, line + "\n", encoding);
272279
}
273280
}

0 commit comments

Comments
 (0)