fix #83 import-aware quickdocs
This commit is contained in:
1 parent
40f11b6f29
commit
bfffea7e69
8 files changed
+345
-58
No files matched your search
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Filesystem module builtin docs registration, located in lyngio so core library
|
||||
* does not depend on external packages. The IDEA plugin (and any other tooling)
|
||||
* may reflectively call FsBuiltinDocs.ensure() to make sure docs are registered.
|
||||
*/
|
||||
package net.sergeych.lyngio.docs
|
||||
|
||||
import net.sergeych.lyng.miniast.BuiltinDocRegistry
|
||||
import net.sergeych.lyng.miniast.ParamDoc
|
||||
import net.sergeych.lyng.miniast.TypeGenericDoc
|
||||
import net.sergeych.lyng.miniast.type
|
||||
|
||||
object FsBuiltinDocs {
|
||||
private var registered = false
|
||||
|
||||
fun ensure() {
|
||||
if (registered) return
|
||||
// Register docs immediately (not lazy) so tooling can see them without executing module builders
|
||||
BuiltinDocRegistry.module("lyng.io.fs") {
|
||||
// Class Path with a short summary
|
||||
classDoc(
|
||||
name = "Path",
|
||||
doc = "Filesystem path class. Construct with a string: `Path(\"/tmp\")`."
|
||||
) {
|
||||
// Common instance methods (subset sufficient for Quick Docs)
|
||||
method(
|
||||
name = "exists",
|
||||
doc = "Whether the path exists on the filesystem.",
|
||||
returns = type("lyng.Bool")
|
||||
)
|
||||
method(
|
||||
name = "isFile",
|
||||
doc = "Whether the path exists and is a file.",
|
||||
returns = type("lyng.Bool")
|
||||
)
|
||||
method(
|
||||
name = "isDir",
|
||||
doc = "Whether the path exists and is a directory.",
|
||||
returns = type("lyng.Bool")
|
||||
)
|
||||
method(
|
||||
name = "readUtf8",
|
||||
doc = "Read the entire file as UTF-8 string.",
|
||||
returns = type("lyng.String")
|
||||
)
|
||||
method(
|
||||
name = "writeUtf8",
|
||||
doc = "Write UTF-8 string to the file (overwrite).",
|
||||
params = listOf(ParamDoc("text", type("lyng.String")))
|
||||
)
|
||||
method(
|
||||
name = "bytes",
|
||||
doc = "Iterate file content as `Buffer` chunks.",
|
||||
params = listOf(ParamDoc("size", type("lyng.Int"))),
|
||||
returns = TypeGenericDoc(type("lyng.Iterator"), listOf(type("lyng.Buffer")))
|
||||
)
|
||||
method(
|
||||
name = "lines",
|
||||
doc = "Iterate file as lines of text.",
|
||||
returns = TypeGenericDoc(type("lyng.Iterator"), listOf(type("lyng.String")))
|
||||
)
|
||||
}
|
||||
|
||||
// Top-level exported constants
|
||||
valDoc(
|
||||
name = "Path",
|
||||
doc = "Filesystem path class. Construct with a string: `Path(\"/tmp\")`.",
|
||||
type = type("Path")
|
||||
)
|
||||
valDoc(
|
||||
name = "Paths",
|
||||
doc = "Alias of `Path` for those who prefer plural form.",
|
||||
type = type("Path")
|
||||
)
|
||||
}
|
||||
registered = true
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user