-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add an anchor_links
parameter to gr.ParamViewer
that allows linking to specific parameters.
#10495
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-pypi-previews.s3.amazonaws.com/f331adcd354ebe18c74608a76dc229b70270d929/gradio-5.14.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@f331adcd354ebe18c74608a76dc229b70270d929#subdirectory=client/python" Install Gradio JS Client from this PR npm install https://gradio-npm-previews.s3.amazonaws.com/f331adcd354ebe18c74608a76dc229b70270d929/gradio-client-1.10.0.tgz Use Lite from this PR <script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/f331adcd354ebe18c74608a76dc229b70270d929/dist/lite.js""></script> |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
@abidlabs, there's a problem in your website code that if there are multiple params on the page with the same name, they're both getting the same id so the linking gets broken because it doesn't know which to reference. For example, the docs for interface has fn paramater in the class and also in load. Both get the id "param-fn" so this link is broken: https://d3a08c02.gradio-website.pages.dev/docs/gradio/interface#param-fn It should be param-{class/function name}-{param-name} I've done something similar before. so let me fix this |
Ah right of course, thanks for taking care of it! |
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.
LGTM now!
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.
nevermind. like you notes @abidlabs this won't work because it will change the hash everything the website rebuilds. working on new fix now
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.
Ok @abidlabs. based on your suggestion you can now pass a string to anchor_links that will act as a prefix.
I tested this with the website and this modified demo:
import gradio as gr
with gr.Blocks() as demo:
gr.Markdown("The `round()` function in Python takes two parameters"*1000)
gr.ParamViewer(
{
"number": {
"type": "int | float",
"description": "The number to round",
"default": None
},
"ndigits": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
},
"ndigits2": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
},
"ndigits3": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
},
"ndigits4": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
},
"ndigits5": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
}
},
anchor_links=True,
)
gr.ParamViewer(
{
"number": {
"type": "int | float",
"description": "The number to round",
"default": None
},
"ndigits": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
},
"ndigits2": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
},
"ndigits3": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
},
"ndigits4": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
},
"ndigits5": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
}
},
anchor_links=False,
)
gr.ParamViewer(
{
"number": {
"type": "int | float",
"description": "The number to round",
"default": None
},
"ndigits": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
},
"ndigits2": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
},
"ndigits3": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
},
"ndigits4": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
},
"ndigits5": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
}
},
anchor_links="bananas",
)
gr.ParamViewer(
{
"number": {
"type": "int | float",
"description": "The number to round",
"default": None
},
"ndigits": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
},
"ndigits2": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
},
"ndigits3": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
},
"ndigits4": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
},
"ndigits5": {
"type": "int",
"description": "The number of digits to round to",
"default": "0",
}
},
anchor_links="",
)
if __name__ == "__main__":
demo.launch()
And it's working great. Because paramtable.svelte wasn't passing fn/class names i had to edit all the svx files. but now should be good to go. please take a look at my changes though
LGTM @aliabd thanks so much for the fix! |
Closes: #10339 and updates our docs to use this.
Test with: