Skip to content

Docgen(fix): Remove formatCode function #836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions analysis/src/DocExtraction.ml
Original file line number Diff line number Diff line change
@@ -48,15 +48,6 @@ and docsForModule = {
items: docItem list;
}

let formatCode content =
let {Res_driver.parsetree = signature; comments} =
Res_driver.parseInterfaceFromSource ~forPrinter:true
~displayFilename:"<missing-file>" ~source:content
in
Res_printer.printInterface ~width:!Res_cli.ResClflags.width ~comments
signature
|> String.trim

let stringifyDocstrings docstrings =
let open Protocol in
docstrings
@@ -282,8 +273,7 @@ let extractDocs ~path ~debug =
id = modulePath |> makeId ~identifier:item.name;
docstring = item.docstring |> List.map String.trim;
signature =
"let " ^ item.name ^ ": " ^ Shared.typeToString typ
|> formatCode;
"let " ^ item.name ^ ": " ^ Shared.typeToString typ;
name = item.name;
deprecated = item.deprecated;
})
@@ -293,10 +283,7 @@ let extractDocs ~path ~debug =
{
id = modulePath |> makeId ~identifier:item.name;
docstring = item.docstring |> List.map String.trim;
signature =
typ.decl
|> Shared.declToString item.name
|> formatCode;
signature = typ.decl |> Shared.declToString item.name;
name = item.name;
deprecated = item.deprecated;
detail = typeDetail typ ~full ~env;
2 changes: 1 addition & 1 deletion analysis/tests/src/expected/DocExtractionRes.res.txt
Original file line number Diff line number Diff line change
@@ -118,7 +118,7 @@ extracting docs for src/DocExtractionRes.res
"id": "DocExtractionRes.AnotherModule.someVariantWithInlineRecords",
"kind": "type",
"name": "someVariantWithInlineRecords",
"signature": "type someVariantWithInlineRecords = SomeStuff({offline: bool})",
"signature": "type someVariantWithInlineRecords =\\n | SomeStuff({offline: bool})",
"docstrings": ["Trying how it looks with an inline record in a variant."],
"detail":
{