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

Improve styling of parameter tables in the docs #8618

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Conversation

abidlabs
Copy link
Member

@abidlabs abidlabs commented Jun 25, 2024

Change the styling of the parameter tables in the docs to be consistent with the view api docs. Our current design wastes a lot of whitespace when the docstrings are short or very long, forcing users to scroll a lot when e.g. they want to see the example usage

BEFORE:

image

AFTER:

image

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Jun 25, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/a34c253ef160c20d2ecd9ed91205141e796d7ae5/gradio-4.37.1-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@a34c253ef160c20d2ecd9ed91205141e796d7ae5#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-builds.s3.amazonaws.com/a34c253ef160c20d2ecd9ed91205141e796d7ae5/gradio-client-1.2.0.tgz

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Jun 25, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
website patch
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Improve styling of parameter tables in the docs

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@abidlabs abidlabs changed the title param table Style parameter tables in the docs Jun 25, 2024
@abidlabs abidlabs added the v: patch A change that requires a patch release label Jun 25, 2024
@pngwn
Copy link
Member

pngwn commented Jun 25, 2024

I don't really love this for long types, they are unreadable of which we have many: https://gradio-9e0pzuzft-hugging-face.vercel.app/docs/gradio/annotatedimage

I think the ParamViewer offers a better compromise: https://huggingface.co/spaces/pngwn/gradio_imageslider

@abidlabs
Copy link
Member Author

@pngwn I can split the types across multiple lines when its a union of types to avoid the issue you're mentioning

Stylistically, I think gr.ParamViewer would look out of place on our docs page. And one thing I don't like like about it is how the docstrings are hidden by default -- they should always be visible to make it easier to cmd+f and find what you're looking for

@abidlabs
Copy link
Member Author

Actually I just made it wrap to the next line and I think this looks pretty good:

image image

wdyt @pngwn @aliabd?

@aliabd
Copy link
Collaborator

aliabd commented Jun 26, 2024

@abidlabs this looks great, though i wish there was better styling for the Default: / Required part. Maybe keep that as it is currently?

Screen Shot 2024-06-25 at 8 18 10 PM

@abidlabs abidlabs marked this pull request as ready for review June 26, 2024 17:11
@abidlabs abidlabs changed the title Style parameter tables in the docs Improve styling of parameter tables in the docs Jun 26, 2024
@freddyaboulton
Copy link
Collaborator

The proposed styling looks nice! I do think it would be best if we could consolidate the desired "param table style" in the ParamViewer component. That way all parameter tables (custom components, docs, api docs) would be consistent.

Copy link
Collaborator

@aliabd aliabd left a comment

Choose a reason for hiding this comment

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

Changes look good to me @abidlabs. I agree with @freddyaboulton that it would be nice to be consistent everywhere.

You have to make the changes to FunctionDoc.svelte as well (like you did for EventListeners.svelte). Right now it's still the old table styling.

Screen Shot 2024-06-27 at 12 02 41 PM

@pngwn
Copy link
Member

pngwn commented Jun 28, 2024

I think don't think the compound/ complex types are really that readable. You can read them now but it is still almost impossible to understand the relationship between the different parts (ie nested bits, unions, etc) without some proper formatting.

@pngwn
Copy link
Member

pngwn commented Jun 28, 2024

I personally think the docstrings are too long to be visible all of the time, we have too many kwargs for that. If you want to see anything else then you have an awful experience.

@abidlabs
Copy link
Member Author

I think don't think the compound/ complex types are really that readable. You can read them now but it is still almost impossible to understand the relationship between the different parts (ie nested bits, unions, etc) without some proper formatting.

Ok with changing this, but how would you suggest formatting them @pngwn?

I personally think the docstrings are too long to be visible all of the time, we have too many kwargs for that. If you want to see anything else then you have an awful experience.

I don't think that's the case, you can easily navigate to the different sections using the sidebar on the right. Having all of the docstrings makes it much easier to CMD+F and find what you're looking for. I strongly dislike when documentation is partially hidden as it makes search completely unreliable

You have to make the changes to FunctionDoc.svelte as well (like you did for EventListeners.svelte). Right now it's still the old table styling.

Can make this change!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v: patch A change that requires a patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants