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

generate docs when running gradio cc build #7109

Merged
merged 9 commits into from Jan 24, 2024
Merged

generate docs when running gradio cc build #7109

merged 9 commits into from Jan 24, 2024

Conversation

pngwn
Copy link
Member

@pngwn pngwn commented Jan 22, 2024

Description

Runs the docs generator as part of the build. This only provides defaults with no options (so as not to bloat the build command). If you users wish to customise the behaviour, they can use the docs command.

Added new arg to build to optionally disbale the docs gen:

gradio cc build --no-generate-docs

Related to #7080.

Please include a concise summary, in clear English, of the changes in this pull request. If it closes an issue, please mention it here.

Closes: #(issue)

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Tests

  1. PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests: bash scripts/run_all_tests.sh

  2. You may need to run the linters: bash scripts/format_backend.sh and bash scripts/format_frontend.sh

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Jan 22, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
Visual tests all good! Build review
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/90822d32cc13bfd24fd7075ebbb1efb073491569/gradio-4.15.0-py3-none-any.whl

Install Gradio Python Client from this PR

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

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Jan 22, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/paramviewer minor
gradio minor
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

generate docs when running gradio cc build

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.

@pngwn pngwn changed the title add docs command to build generate docs when running graido cc build Jan 22, 2024
@pngwn pngwn changed the title generate docs when running graido cc build generate docs when running gradio cc build Jan 22, 2024

name = get_deep(data, ["project", "name"])

if not isinstance(name, str):
raise ValueError("Name not found in pyproject.toml")

pypi_exists = requests.get(f"https://pypi.org/pypi/{name}/json").status_code
run_command(
Copy link
Collaborator

Choose a reason for hiding this comment

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

The warning about python 3.9 needs to be printed with live otherwise it's out of order:

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would maybe skip the "Generating documentation" and just print the "Documentation generated..." but something like

Documentation generated in demo/app.py and README.md. Pass `--no-generate-docs` to disable auto documentation

Copy link
Member Author

Choose a reason for hiding this comment

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

I kinda wanted it to be not in the live panel because there isn't actually an issue with the doc gen, just a note. But I can put it at the bottom with some space.

Will update the message.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks great! My bad, I think we should remove the backticks around --no-generate-docs since they don't change. how it renders

Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

Looks great @pngwn ! Just noticed two things about the CLI output.


name = get_deep(data, ["project", "name"])

if not isinstance(name, str):
raise ValueError("Name not found in pyproject.toml")

pypi_exists = requests.get(f"https://pypi.org/pypi/{name}/json").status_code
run_command(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would maybe skip the "Generating documentation" and just print the "Documentation generated..." but something like

Documentation generated in demo/app.py and README.md. Pass `--no-generate-docs` to disable auto documentation

@pngwn
Copy link
Member Author

pngwn commented Jan 22, 2024

@freddyaboulton fixed (i think)!

Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

Thanks @pngwn !


name = get_deep(data, ["project", "name"])

if not isinstance(name, str):
raise ValueError("Name not found in pyproject.toml")

pypi_exists = requests.get(f"https://pypi.org/pypi/{name}/json").status_code
run_command(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks great! My bad, I think we should remove the backticks around --no-generate-docs since they don't change. how it renders

@pngwn
Copy link
Member Author

pngwn commented Jan 22, 2024

done!

short_readme_path = Path(_readme_path).relative_to(_component_dir)
short_demo_path = Path(_demo_path).relative_to(_component_dir)
live.update(
f":white_check_mark: Documention generated in [orange3]{short_demo_path}[/] and [orange3]{short_readme_path}[/]. Pass --no-generate-docs to disable auto documentation."
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be space.py not demo.py no?

image

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed!

@pngwn
Copy link
Member Author

pngwn commented Jan 22, 2024

I've also tweaked the ParamViewer so that it does not show a toggle if there is no content.

@pngwn pngwn merged commit 125a832 into main Jan 24, 2024
13 checks passed
@pngwn pngwn deleted the cc-docs-build branch January 24, 2024 18:12
@pngwn pngwn mentioned this pull request Jan 24, 2024
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.

None yet

3 participants