mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 03:54:51 +00:00
pyrofork: Refactor docs build script
Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
parent
b43e857ed2
commit
e9c40679d2
3 changed files with 106 additions and 37 deletions
21
.github/workflows/build-docs.yml
vendored
21
.github/workflows/build-docs.yml
vendored
|
|
@ -14,8 +14,25 @@ jobs:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
steps:
|
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
|
- 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:
|
env:
|
||||||
DOCS_KEY: ${{ secrets.DOCS_KEY }}
|
DOCS_KEY: ${{ secrets.DOCS_KEY }}
|
||||||
|
|
||||||
|
- name: Push changes
|
||||||
|
run: bash build-docs.sh push
|
||||||
|
|
|
||||||
115
build-docs.sh
115
build-docs.sh
|
|
@ -1,42 +1,87 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
export DOCS_KEY
|
|
||||||
VENV="$(pwd)"/venv
|
|
||||||
export VENV
|
|
||||||
|
|
||||||
if [[ "$(echo "$GITHUB_REF" | cut -d '/' -f "1 2")" == "refs/tags" ]]; then
|
# Check if config.sh exists
|
||||||
branch="main"
|
if [ -f config.sh ]; then
|
||||||
elif [[ "$GITHUB_REF" == "refs/heads/staging" ]]; then
|
source config.sh
|
||||||
branch="staging"
|
fi
|
||||||
else
|
|
||||||
b="$(echo "$GITHUB_REF" | cut -d '/' -f '3 4')"
|
function parse_parameters() {
|
||||||
if [[ $(echo "$b" | cut -d '/' -f 1 ) == "dev" ]]; then
|
while (($#)); do
|
||||||
b="$(echo "$b" | cut -d '/' -f 2)"
|
case $1 in
|
||||||
if [[ "$b" =~ ^[0-9]\.[0-9]\.x ]]; then
|
all | configure | cleanup | virtualenv | build | clone | push ) action=$1 ;;
|
||||||
branch="$b"
|
*) 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
|
else
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
fi
|
chmod +x config.sh
|
||||||
|
}
|
||||||
|
|
||||||
make clean
|
function do_cleanup() {
|
||||||
make clean-docs
|
make clean
|
||||||
make venv
|
make clean-docs
|
||||||
make api
|
}
|
||||||
"$VENV"/bin/pip install -e '.[docs]'
|
|
||||||
cd compiler/docs || exit 1 && "$VENV"/bin/python compiler.py
|
function do_virtualenv() {
|
||||||
cd ../.. || exit 1
|
make venv
|
||||||
"$VENV"/bin/sphinx-build -b html "docs/source" "docs/build/html" -j auto
|
make api
|
||||||
git clone https://wulan17:"$DOCS_KEY"@github.com/Mayuri-Chan/pyrofork-docs.git
|
"$VENV"/bin/pip install -e '.[docs]'
|
||||||
cd pyrofork-docs || exit 1
|
}
|
||||||
mkdir -p "$branch"
|
|
||||||
cd "$branch" || exit 1
|
function do_build() {
|
||||||
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
|
cd compiler/docs || exit 1 && "$VENV"/bin/python compiler.py
|
||||||
cp -r ../../docs/build/html/* .
|
cd ../.. || exit 1
|
||||||
git config --local user.name "Mayuri-Chan"
|
"$VENV"/bin/sphinx-build -b html "docs/source" "docs/build/html" -j auto
|
||||||
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
|
function do_clone() {
|
||||||
git push -u origin --all
|
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}"
|
||||||
|
|
|
||||||
|
|
@ -28,17 +28,24 @@ class GetCollectibleItemInfo:
|
||||||
phone_number: str = None
|
phone_number: str = None
|
||||||
) -> "types.CollectibleInfo":
|
) -> "types.CollectibleInfo":
|
||||||
"""Returns information about a given collectible item that was purchased at https://fragment.com
|
"""Returns information about a given collectible item that was purchased at https://fragment.com
|
||||||
|
|
||||||
.. include:: /_includes/usable-by/users.rst
|
.. include:: /_includes/usable-by/users.rst
|
||||||
|
|
||||||
You must use exactly one of ``username`` OR ``phone_number``.
|
You must use exactly one of ``username`` OR ``phone_number``.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
username (``str``, *optional*):
|
username (``str``, *optional*):
|
||||||
Describes a collectible username that can be purchased at https://fragment.com
|
Describes a collectible username that can be purchased at https://fragment.com
|
||||||
|
|
||||||
phone_number (``str``, *optional*):
|
phone_number (``str``, *optional*):
|
||||||
Describes a collectible phone number that can be purchased at https://fragment.com
|
Describes a collectible phone number that can be purchased at https://fragment.com
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
:obj:`~pyrogram.types.CollectibleInfo`: On success, a collectible info is returned.
|
:obj:`~pyrogram.types.CollectibleInfo`: On success, a collectible info is returned.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
username = await app.get_collectible_item_info(username="nerd")
|
username = await app.get_collectible_item_info(username="nerd")
|
||||||
print(username)
|
print(username)
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue