Skip to content

Frontend for yields & raises docstrings#141

Merged
mishig25 merged 14 commits into
mainfrom
frontend_yields_raises
Sep 5, 2022
Merged

Frontend for yields & raises docstrings#141
mishig25 merged 14 commits into
mainfrom
frontend_yields_raises

Conversation

@mishig25

@mishig25 mishig25 commented Mar 15, 2022

Copy link
Copy Markdown
Contributor

closes #172

Screenshot 2022-03-15 at 17 51 44

Screenshot 2022-03-15 at 17 58 23

@mishig25 mishig25 force-pushed the frontend_yields_raises branch from a5af068 to 12e3040 Compare March 15, 2022 16:51
@mishig25 mishig25 marked this pull request as draft April 6, 2022 07:59
@mishig25 mishig25 force-pushed the frontend_yields_raises branch from 1ee6f1d to 8a881a1 Compare April 6, 2022 08:09
@mishig25 mishig25 marked this pull request as ready for review April 6, 2022 08:57

@coyotte508 coyotte508 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Comment thread kit/preprocess.js
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
Copy Markdown
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

sgugger commented Apr 6, 2022

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Member

I like the current approach! Thanks @mishig25!

@mishig25

mishig25 commented Apr 8, 2022

Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
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
Copy Markdown
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