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
fa4ffef8ff
commit
acc477db57
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
|
||||
|
||||
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
|
||||
|
|
|
|||
115
build-docs.sh
115
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}"
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue