mirror of
https://github.com/lune-org/lune.git
synced 2024-12-13 13:30:38 +00:00
Fix docs file not parsing because of declare class syntax
This commit is contained in:
parent
091dc17337
commit
adc503d6ae
2 changed files with 31 additions and 3 deletions
|
@ -240,7 +240,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"documentation": "@roblox/global/net.serve/param/1",
|
"documentation": "@roblox/global/net.serve/param/1",
|
||||||
"name": "handler"
|
"name": "handlerOrConfig"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"returns": []
|
"returns": []
|
||||||
|
@ -249,7 +249,27 @@
|
||||||
"documentation": "The port to use for the server"
|
"documentation": "The port to use for the server"
|
||||||
},
|
},
|
||||||
"@roblox/global/net.serve/param/1": {
|
"@roblox/global/net.serve/param/1": {
|
||||||
"documentation": "The handler function to use for the server"
|
"documentation": "The handler function or config to use for the server"
|
||||||
|
},
|
||||||
|
"@roblox/global/net.socket": {
|
||||||
|
"code_sample": "",
|
||||||
|
"documentation": "Connects to a web socket at the given URL.\n\nThrows an error if the server at the given URL does not support\nweb sockets, or if a miscellaneous network or I/O error occurs.",
|
||||||
|
"learn_more_link": "",
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"documentation": "@roblox/global/net.socket/param/0",
|
||||||
|
"name": "url"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"returns": [
|
||||||
|
"@roblox/global/net.socket/return/0"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"@roblox/global/net.socket/param/0": {
|
||||||
|
"documentation": "The URL to connect to"
|
||||||
|
},
|
||||||
|
"@roblox/global/net.socket/return/0": {
|
||||||
|
"documentation": "A web socket handle"
|
||||||
},
|
},
|
||||||
"@roblox/global/process": {
|
"@roblox/global/process": {
|
||||||
"code_sample": "",
|
"code_sample": "",
|
||||||
|
|
|
@ -13,11 +13,19 @@ mod visitor;
|
||||||
use self::{doc::DocsFunctionParamLink, visitor::DocumentationVisitor};
|
use self::{doc::DocsFunctionParamLink, visitor::DocumentationVisitor};
|
||||||
|
|
||||||
fn parse_definitions(contents: &str) -> Result<DocumentationVisitor> {
|
fn parse_definitions(contents: &str) -> Result<DocumentationVisitor> {
|
||||||
|
// TODO: Properly handle the "declare class" syntax, for now we just skip it
|
||||||
|
let mut no_declares = contents.to_string();
|
||||||
|
while let Some(dec) = no_declares.find("\ndeclare class") {
|
||||||
|
let end = no_declares.find("\nend").unwrap();
|
||||||
|
let before = &no_declares[0..dec];
|
||||||
|
let after = &no_declares[end + 4..];
|
||||||
|
no_declares = format!("{before}{after}");
|
||||||
|
}
|
||||||
let (regex, replacement) = (
|
let (regex, replacement) = (
|
||||||
Regex::new(r#"declare (?P<n>\w+): "#).unwrap(),
|
Regex::new(r#"declare (?P<n>\w+): "#).unwrap(),
|
||||||
r#"export type $n = "#,
|
r#"export type $n = "#,
|
||||||
);
|
);
|
||||||
let defs_ast = parse_luau_ast(®ex.replace_all(contents, replacement))?;
|
let defs_ast = parse_luau_ast(®ex.replace_all(&no_declares, replacement))?;
|
||||||
let mut visitor = DocumentationVisitor::new();
|
let mut visitor = DocumentationVisitor::new();
|
||||||
visitor.visit_ast(&defs_ast);
|
visitor.visit_ast(&defs_ast);
|
||||||
Ok(visitor)
|
Ok(visitor)
|
||||||
|
|
Loading…
Reference in a new issue