mirror of
https://github.com/gradio-app/gradio.git
synced 2025-03-31 12:20:26 +08:00
Remove old versioned docs and fix repo classification (#4362)
* remove old versioned docs * delete versioned docs when new one is created * ignore website dir in linguist calc * upload and download versioned docs * modify github action * remove gitattributes file --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
parent
8f0bd10be7
commit
a43531cc4b
11
.github/workflows/build-version-docs.yml
vendored
11
.github/workflows/build-version-docs.yml
vendored
@ -38,11 +38,6 @@ jobs:
|
||||
- name: Install gradio
|
||||
run: python -m pip install gradio==$(cat gradio/version.txt)
|
||||
- name: Build Docs
|
||||
run: cd website/homepage && python build-version-docs.py
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v4
|
||||
with:
|
||||
add: website/homepage/src/*
|
||||
author_name: "GH ACTIONS"
|
||||
author_email: ""
|
||||
title: "New Version Docs"
|
||||
run: |
|
||||
export HF_AUTH_TOKEN=${{ secrets.HF_AUTH_TOKEN }}
|
||||
cd website/homepage && python build-version-docs.py
|
3
website/.gitignore
vendored
3
website/.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
client_secrets.json
|
||||
google_credentials.json
|
||||
google_credentials.json
|
||||
homepage/src/docs/v*_template.html
|
@ -1,10 +1,13 @@
|
||||
import os
|
||||
import shutil
|
||||
from huggingface_hub import upload_file
|
||||
import tempfile
|
||||
|
||||
import jinja2
|
||||
from src import docs
|
||||
from utils import get_latest_stable
|
||||
|
||||
AUTH_TOKEN = os.getenv("HF_AUTH_TOKEN")
|
||||
SRC_DIR = "src"
|
||||
BUILD_DIR = "build"
|
||||
if os.path.exists(BUILD_DIR):
|
||||
@ -12,9 +15,18 @@ if os.path.exists(BUILD_DIR):
|
||||
os.makedirs(BUILD_DIR)
|
||||
jinja_env = jinja2.Environment(loader=jinja2.FileSystemLoader(SRC_DIR))
|
||||
|
||||
shutil.copytree(
|
||||
os.path.join(SRC_DIR, "assets"), os.path.join(BUILD_DIR, "assets")
|
||||
)
|
||||
shutil.copytree(os.path.join(SRC_DIR, "assets"), os.path.join(BUILD_DIR, "assets"))
|
||||
|
||||
latest_gradio_stable = get_latest_stable()
|
||||
docs.build_pip_template(latest_gradio_stable , jinja_env)
|
||||
new_version_docs = docs.build_pip_template(latest_gradio_stable, jinja_env)
|
||||
|
||||
with tempfile.NamedTemporaryFile() as tmp:
|
||||
with open(tmp.name, "w") as tmp_file:
|
||||
tmp_file.write(new_version_docs)
|
||||
upload_file(
|
||||
path_or_fileobj=tmp.name,
|
||||
repo_type="dataset",
|
||||
path_in_repo=f"v{latest_gradio_stable}_template.html",
|
||||
repo_id="gradio/docs",
|
||||
token=AUTH_TOKEN,
|
||||
)
|
||||
|
@ -4,6 +4,7 @@ import re
|
||||
from gradio_client.documentation import document_cls, generate_documentation
|
||||
from gradio.events import EventListener
|
||||
import markdown2
|
||||
from urllib.request import urlretrieve
|
||||
|
||||
|
||||
from ..guides import guides
|
||||
@ -61,7 +62,19 @@ def add_demos():
|
||||
|
||||
add_demos()
|
||||
|
||||
ordered_events = ["Change()", "Click()", "Submit()", "Edit()", "Clear()", "Play()", "Pause()", "Stream()", "Blur()", "Upload()"]
|
||||
ordered_events = [
|
||||
"Change()",
|
||||
"Click()",
|
||||
"Submit()",
|
||||
"Edit()",
|
||||
"Clear()",
|
||||
"Play()",
|
||||
"Pause()",
|
||||
"Stream()",
|
||||
"Blur()",
|
||||
"Upload()",
|
||||
]
|
||||
|
||||
|
||||
def add_supported_events():
|
||||
for component in docs["component"]:
|
||||
@ -147,27 +160,26 @@ def find_cls(target_cls):
|
||||
|
||||
|
||||
def build_js_client():
|
||||
with open(JS_CLIENT_README, "r") as f:
|
||||
js_docs = f.read()
|
||||
js_docs = re.sub(
|
||||
r"```([a-z]+)\n",
|
||||
lambda x: f"<div class='codeblock'><pre><code class='lang-{x.group(1)}'>",
|
||||
js_docs,
|
||||
with open(JS_CLIENT_README, "r") as f:
|
||||
js_docs = f.read()
|
||||
js_docs = re.sub(
|
||||
r"```([a-z]+)\n",
|
||||
lambda x: f"<div class='codeblock'><pre><code class='lang-{x.group(1)}'>",
|
||||
js_docs,
|
||||
)
|
||||
js_docs = re.sub(r"```", "</code></pre></div>", js_docs)
|
||||
with open(TEMP_TEMPLATE, "w") as temp_html:
|
||||
temp_html.write(
|
||||
markdown2.markdown(
|
||||
js_docs,
|
||||
extras=[
|
||||
"target-blank-links",
|
||||
"header-ids",
|
||||
"tables",
|
||||
"fenced-code-blocks",
|
||||
],
|
||||
)
|
||||
)
|
||||
js_docs = re.sub(r"```", "</code></pre></div>", js_docs)
|
||||
with open(TEMP_TEMPLATE, "w") as temp_html:
|
||||
temp_html.write(
|
||||
markdown2.markdown(
|
||||
js_docs,
|
||||
extras=[
|
||||
"target-blank-links",
|
||||
"header-ids",
|
||||
"tables",
|
||||
"fenced-code-blocks",
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
def build(output_dir, jinja_env, gradio_wheel_url, gradio_version):
|
||||
@ -181,7 +193,7 @@ def build(output_dir, jinja_env, gradio_wheel_url, gradio_version):
|
||||
version="main",
|
||||
gradio_version=gradio_version,
|
||||
gradio_wheel_url=gradio_wheel_url,
|
||||
canonical_suffix="/main"
|
||||
canonical_suffix="/main",
|
||||
)
|
||||
output_folder = os.path.join(output_dir, "docs")
|
||||
os.makedirs(output_folder)
|
||||
@ -190,6 +202,11 @@ def build(output_dir, jinja_env, gradio_wheel_url, gradio_version):
|
||||
output_file = os.path.join(output_main, "index.html")
|
||||
with open(output_file, "w") as index_html:
|
||||
index_html.write(output)
|
||||
if not os.path.exists(f"v{gradio_version}_template.html"):
|
||||
urlretrieve(
|
||||
f"https://huggingface.co/datasets/gradio/docs/resolve/main/v{gradio_version}_template.html",
|
||||
f"src/docs/v{gradio_version}_template.html",
|
||||
)
|
||||
template = jinja_env.get_template(f"docs/v{gradio_version}_template.html")
|
||||
output = template.render()
|
||||
version_docs_file = os.path.join(output_folder, "index.html")
|
||||
@ -201,7 +218,11 @@ def build_pip_template(version, jinja_env):
|
||||
build_js_client()
|
||||
template = jinja_env.get_template("docs/template.html")
|
||||
output = template.render(
|
||||
docs=docs, find_cls=find_cls, version="pip", gradio_version=version, canonical_suffix="", ordered_events=ordered_events
|
||||
docs=docs,
|
||||
find_cls=find_cls,
|
||||
version="pip",
|
||||
gradio_version=version,
|
||||
canonical_suffix="",
|
||||
ordered_events=ordered_events,
|
||||
)
|
||||
with open(f"src/docs/v{version}_template.html", "w+") as template_file:
|
||||
template_file.write(output)
|
||||
return output
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user