Skip to content
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

Frontend for yields & raises docstrings #141

Merged
merged 14 commits into from
Sep 5, 2022
Merged

Conversation

mishig25
Copy link
Contributor

@mishig25 mishig25 commented Mar 15, 2022

closes #172

Screenshot 2022-03-15 at 17 51 44

Screenshot 2022-03-15 at 17 58 23

@mishig25 mishig25 marked this pull request as draft April 6, 2022 07:59
@mishig25 mishig25 marked this pull request as ready for review April 6, 2022 08:57
Copy link
Member

@coyotte508 coyotte508 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines 97 to 116
svelteComponent += ` returnDescription={${JSON.stringify(code)}} `;
}

if (docstringBody.match(REGEX_YIELDTYPE)) {
const yieldType = docstringBody.match(REGEX_YIELDTYPE)[1];
const { code } = await mdsvexPreprocess.markup({ content: yieldType, filename });
svelteComponent += ` returnType={${JSON.stringify(code)}} isYield={true} `;
}

if (docstringBody.match(REGEX_RAISEDESC)) {
const raiseDesc = docstringBody.match(REGEX_RAISEDESC)[1];
const { code } = await mdsvexPreprocess.markup({ content: raiseDesc, filename });
svelteComponent += ` raiseDescription={${JSON.stringify(code)}} `;
}

if (docstringBody.match(REGEX_RAISETYPE)) {
const raiseType = docstringBody.match(REGEX_RAISETYPE)[1];
const { code } = await mdsvexPreprocess.markup({ content: raiseType, filename });
svelteComponent += ` raiseType={${JSON.stringify(code)}} `;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually, something like a key/value map for the properties and generating the component string at once seems cleaner (rather than multiple svellteComponent += ... followed by a closing tag)

@sgugger
Copy link
Contributor

sgugger commented Apr 6, 2022

I know @LysandreJik was using warning blocks for the raises block to have something in color. Not sure whether it's something we want or not.

@LysandreJik
Copy link
Member

I like the current approach! Thanks @mishig25!

@mishig25
Copy link
Contributor Author

mishig25 commented Apr 8, 2022

@LysandreJik

I like the current approach! Thanks @mishig25!

do you mean: you prefer using for the raise?
if so, should I make this PR only render yields, which should look like returns?

@LysandreJik
Copy link
Member

Sorry, just realized I didn't answer: I was mentioning I like the approach you have taken in your PR, @mishig25

@LysandreJik
Copy link
Member

Bump on this, we're using Raises quite a bit in huggingface_hub and we would benefit from having this in :)

cc @Wauplin

mishig25 added a commit to huggingface/huggingface_hub that referenced this pull request Sep 5, 2022
@mishig25 mishig25 merged commit b648e06 into main Sep 5, 2022
@mishig25 mishig25 deleted the frontend_yields_raises branch September 5, 2022 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Raises and Yields directives are not shown correctly
4 participants