Skip to content
Merged

Beta #119

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/fetch_mtproto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ jobs:
FORCE_UPDATE="--force-update"
fi

set +e
python dev_tools/check_api_schema_updates.py $FORCE_UPDATE
EXIT_CODE=$?
set -e

if [ $EXIT_CODE -eq 0 ]; then
echo "updates_detected=true" >> $GITHUB_OUTPUT
Expand Down
22 changes: 18 additions & 4 deletions compiler/docs/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import shutil
from pathlib import Path

from tl_generator import TLDocGenerator

# Paths
page_template = ""
toctree = ""
Expand Down Expand Up @@ -72,7 +74,7 @@ def snake(s: str):
return re.sub(r"([a-z0-9])([A-Z])", r"\1_\2", s).lower()


def generate_raw(source_path, base) -> None:
def generate_raw(source_path, base, tl_gen: TLDocGenerator) -> None:
all_entities = {}

def build(path, level=0) -> None:
Expand Down Expand Up @@ -121,6 +123,11 @@ def build(path, level=0) -> None:
full_class_path="pyrogram.raw.{}".format(
".".join(full_path.split("/")[:-1]) + "." + name,
),
tl_signature=tl_gen.get_tl_signature(full_name),
parameter_tree=tl_gen.generate_tree(full_name),
example_code=tl_gen.generate_example(
full_name, minimal=(base == TYPES_BASE)
),
),
)

Expand Down Expand Up @@ -500,9 +507,16 @@ def start() -> None:
with Path(HOME, "template/toctree.txt").open(encoding="utf-8") as f:
toctree = f.read()

generate_raw(TYPES_PATH, TYPES_BASE)
generate_raw(FUNCTIONS_PATH, FUNCTIONS_BASE)
generate_raw(BASE_PATH, BASE_BASE)
tl_paths = [
Path(HOME, "../api/source/auth_key.tl"),
Path(HOME, "../api/source/sys_msgs.tl"),
Path(HOME, "../api/source/main_api.tl"),
]
tl_gen = TLDocGenerator(tl_paths)

generate_raw(TYPES_PATH, TYPES_BASE, tl_gen)
generate_raw(FUNCTIONS_PATH, FUNCTIONS_BASE, tl_gen)
generate_raw(BASE_PATH, BASE_BASE, tl_gen)
pyrogram_api()


Expand Down
17 changes: 17 additions & 0 deletions compiler/docs/template/page.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,20 @@

.. autoclass:: {full_class_path}()
:members:

TL Schema
---------

.. code-block:: tl

{tl_signature}

Parameter Tree
--------------

{parameter_tree}

Example
-------

{example_code}
Loading