-
Notifications
You must be signed in to change notification settings - Fork 57
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
Support inline record fields in doc extraction #889
Conversation
Removing the JSON decoding code let a bug surface: Module({
id:
docstrings: array<string>,
deprecated?: string,
name: string,
items: array<item>,
}) having docstrings not being optional, but the generated json (by analysis binary) does not contain the docstrings field for module items. I believe, I found the issue in DocExtraction.ml#L156-166: | Module m ->
stringifyObject ~startOnNewline:true ~indentation
[
("id", Some (wrapInQuotes m.id));
("name", Some (wrapInQuotes m.name));
("kind", Some (wrapInQuotes "module"));
("docstrings", Some (stringifyDocstrings m.docstring)); (* THIS LINE IS MISSING! *)
( "items",
Some
(m.items
|> List.map
(stringifyDocItem ~originalEnv ~indentation:(indentation + 1))
|> array) );
] which doesn't stringified the docstring field yet. |
@woeps perfect, I'll fix it! |
@woeps can you test the latest commits? |
tools/src/Tools_Docgen.resi
Outdated
type constructor = { | ||
name: string, | ||
docstrings: array<string>, | ||
signature: string, | ||
deprecated?: string, | ||
constructorPayload?: constructorPayload, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zth This field name (constructorPayload
) is not matching the field name given in stringifyDetail in DocExtraction.ml
(items
).
If I'm not mistaken, both names need to be identical: either items
or constructorPayload
.
edit:
Just tested it locally: Yes, if I change the fieldname to items
in Tools_Docgen.res(i)
my tests work as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zth changed items
from array to object then better rename field to payload
or params
?
Gabriel, can we remove JSON decode soon (maybe 0.5 release)? At the moment, I use the decode function on the website. |
…ore detail for other constructor payload types as well
6ddba8d
to
430d44e
Compare
Closes #887
I've also removed all of the JSON decoding code, because with untagged variants we can just map to the result zero cost, which is a lot easier to maintain.
cc @aspeddro