From e9c40679d2d1202ef284fa0dd0695316352ba742 Mon Sep 17 00:00:00 2001 From: wulan17 Date: Thu, 11 Dec 2025 00:45:05 +0700 Subject: [PATCH] pyrofork: Refactor docs build script Signed-off-by: wulan17 --- .github/workflows/build-docs.yml | 21 +++- build-docs.sh | 115 ++++++++++++------ .../methods/bots/get_collectible_item_info.py | 7 ++ 3 files changed, 106 insertions(+), 37 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index b523d353..f2b76c5d 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -14,8 +14,25 @@ jobs: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Configure + run: bash build-docs.sh configure + + - name: Cleanup + run: bash build-docs.sh cleanup + + - name: Create virtual environment + run: bash build-docs.sh virtualenv + - name: Build - run: bash build-docs.sh + run: bash build-docs.sh build + + - name: Clone gh-pages repository + run: bash build-docs.sh clone env: DOCS_KEY: ${{ secrets.DOCS_KEY }} + + - name: Push changes + run: bash build-docs.sh push diff --git a/build-docs.sh b/build-docs.sh index 6bdcf148..cd0b3158 100644 --- a/build-docs.sh +++ b/build-docs.sh @@ -1,42 +1,87 @@ #!/bin/bash -export DOCS_KEY -VENV="$(pwd)"/venv -export VENV -if [[ "$(echo "$GITHUB_REF" | cut -d '/' -f "1 2")" == "refs/tags" ]]; then - branch="main" -elif [[ "$GITHUB_REF" == "refs/heads/staging" ]]; then - branch="staging" -else - b="$(echo "$GITHUB_REF" | cut -d '/' -f '3 4')" - if [[ $(echo "$b" | cut -d '/' -f 1 ) == "dev" ]]; then - b="$(echo "$b" | cut -d '/' -f 2)" - if [[ "$b" =~ ^[0-9]\.[0-9]\.x ]]; then - branch="$b" +# Check if config.sh exists +if [ -f config.sh ]; then + source config.sh +fi + +function parse_parameters() { + while (($#)); do + case $1 in + all | configure | cleanup | virtualenv | build | clone | push ) action=$1 ;; + *) exit 33 ;; + esac + shift + done +} + +function do_configure() { + echo "#!/bin/bash" > config.sh + echo "export VENV=\"$(pwd)/venv\"" >> config.sh + + if [[ "$(echo "$GITHUB_REF" | cut -d '/' -f "1 2")" == "refs/tags" ]]; then + echo "export BRANCH=\"main\"" >> config.sh + elif [[ "$GITHUB_REF" == "refs/heads/staging" ]]; then + echo "export BRANCH=\"staging\"" >> config.sh + else + b="$(echo "$GITHUB_REF" | cut -d '/' -f '3 4')" + if [[ $(echo "$b" | cut -d '/' -f 1 ) == "dev" ]]; then + b="$(echo "$b" | cut -d '/' -f 2)" + if [[ "$b" =~ ^[0-9]\.[0-9]\.x ]]; then + echo "export BRANCH=\"$b\"" >> config.sh + else + exit 0 + fi else exit 0 fi - else - exit 0 fi -fi + chmod +x config.sh +} -make clean -make clean-docs -make venv -make api -"$VENV"/bin/pip install -e '.[docs]' -cd compiler/docs || exit 1 && "$VENV"/bin/python compiler.py -cd ../.. || exit 1 -"$VENV"/bin/sphinx-build -b html "docs/source" "docs/build/html" -j auto -git clone https://wulan17:"$DOCS_KEY"@github.com/Mayuri-Chan/pyrofork-docs.git -cd pyrofork-docs || exit 1 -mkdir -p "$branch" -cd "$branch" || exit 1 -rm -rf _includes api genindex.html intro py-modindex.html sitemap.xml support.html topics _static faq index.html objects.inv searchindex.js start telegram -cp -r ../../docs/build/html/* . -git config --local user.name "Mayuri-Chan" -git config --local user.email "mayuri@mayuri.my.id" -git add --all -git commit -a -m "docs: $branch: Update docs $(date '+%Y-%m-%d | %H:%m:%S %p %Z')" --signoff -git push -u origin --all +function do_cleanup() { + make clean + make clean-docs +} + +function do_virtualenv() { + make venv + make api + "$VENV"/bin/pip install -e '.[docs]' +} + +function do_build() { + cd compiler/docs || exit 1 && "$VENV"/bin/python compiler.py + cd ../.. || exit 1 + "$VENV"/bin/sphinx-build -b html "docs/source" "docs/build/html" -j auto +} + +function do_clone() { + git clone https://wulan17:"$DOCS_KEY"@github.com/Mayuri-Chan/pyrofork-docs.git +} + +function do_push() { + cd pyrofork-docs || exit 1 + mkdir -p "$BRANCH" + cd "$BRANCH" || exit 1 + rm -rf _includes api genindex.html intro py-modindex.html sitemap.xml support.html topics _static faq index.html objects.inv searchindex.js start telegram + cp -r ../../docs/build/html/* . + git config --local user.name "Mayuri-Chan" + git config --local user.email "mayuri@mayuri.my.id" + git add --all + git commit -a -m "docs: $BRANCH: Update docs $(date '+%Y-%m-%d | %H:%m:%S %p %Z')" --signoff + git push -u origin --all +} + +function do_all() { + do_configure + source config.sh + do_cleanup + do_virtualenv + do_build + do_clone + do_push +} + +parse_parameters "$@" +do_"${action:=all}" diff --git a/pyrogram/methods/bots/get_collectible_item_info.py b/pyrogram/methods/bots/get_collectible_item_info.py index e96f7313..bbce0d34 100644 --- a/pyrogram/methods/bots/get_collectible_item_info.py +++ b/pyrogram/methods/bots/get_collectible_item_info.py @@ -28,17 +28,24 @@ class GetCollectibleItemInfo: phone_number: str = None ) -> "types.CollectibleInfo": """Returns information about a given collectible item that was purchased at https://fragment.com + .. include:: /_includes/usable-by/users.rst + You must use exactly one of ``username`` OR ``phone_number``. + Parameters: username (``str``, *optional*): Describes a collectible username that can be purchased at https://fragment.com + phone_number (``str``, *optional*): Describes a collectible phone number that can be purchased at https://fragment.com + Returns: :obj:`~pyrogram.types.CollectibleInfo`: On success, a collectible info is returned. + Example: .. code-block:: python + username = await app.get_collectible_item_info(username="nerd") print(username) """