mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-27 08:36:27 +00:00
Update compiler
Co-authored-by: Shrimadhav U K <SpEcHiDe@users.noreply.github.com>
This commit is contained in:
parent
814e2fb30c
commit
8ad4e9a2ab
4
Makefile
4
Makefile
@ -5,7 +5,7 @@ TAG = v$(shell grep -E '__version__ = ".*"' pyrogram/__init__.py | cut -d\" -f2)
|
||||
|
||||
RM := rm -rf
|
||||
|
||||
.PHONY: venv clean-build clean-api clean api build
|
||||
.PHONY: venv clean-build clean-api clean-docs clean api docs build
|
||||
|
||||
venv:
|
||||
$(RM) $(VENV)
|
||||
@ -21,7 +21,7 @@ clean-api:
|
||||
$(RM) pyrogram/errors/exceptions pyrogram/raw/all.py pyrogram/raw/base pyrogram/raw/functions pyrogram/raw/types
|
||||
|
||||
clean-docs:
|
||||
$(RM) docs/build docs/source/api/bound-methods docs/source/api/methods docs/source/api/types docs/source/telegram
|
||||
$(RM) docs/build docs/source/api/bound-methods docs/source/api/methods docs/source/api/types docs/source/api/enums docs/source/telegram
|
||||
|
||||
clean:
|
||||
make clean-build
|
||||
|
@ -824,6 +824,78 @@ def pyrogram_api():
|
||||
f.write(template.format(**fmt_keys))
|
||||
|
||||
|
||||
# Enumerations
|
||||
|
||||
categories = dict(
|
||||
enums="""
|
||||
Enumerations
|
||||
BusinessSchedule
|
||||
ChatAction
|
||||
ChatEventAction
|
||||
ChatMemberStatus
|
||||
ChatMembersFilter
|
||||
ChatType
|
||||
ClientPlatform
|
||||
FolderColor
|
||||
MessageEntityType
|
||||
MessageServiceType
|
||||
MessagesFilter
|
||||
NextCodeType
|
||||
ParseMode
|
||||
PollType
|
||||
PrivacyKey
|
||||
ProfileColor
|
||||
ReplyColor
|
||||
SentCodeType
|
||||
StoriesPrivacyRules
|
||||
UserStatus
|
||||
""",
|
||||
)
|
||||
|
||||
root = PYROGRAM_API_DEST + "/enums"
|
||||
|
||||
shutil.rmtree(root, ignore_errors=True)
|
||||
os.mkdir(root)
|
||||
|
||||
with open(HOME + "/template/enums.rst") as f:
|
||||
template = f.read()
|
||||
|
||||
with open(root + "/cleanup.html", "w") as f:
|
||||
f.write("""<script>
|
||||
document
|
||||
.querySelectorAll("em.property")
|
||||
.forEach((elem, i) => i !== 0 ? elem.remove() : true)
|
||||
|
||||
document
|
||||
.querySelectorAll("a.headerlink")
|
||||
.forEach((elem, i) => [0, 1].includes(i) ? true : elem.remove())
|
||||
</script>""")
|
||||
|
||||
with open(root + "/index.rst", "w") as f:
|
||||
fmt_keys = {}
|
||||
|
||||
for k, v in categories.items():
|
||||
name, *enums = get_title_list(v)
|
||||
|
||||
fmt_keys.update({"{}_hlist".format(k): "\n ".join("{}".format(enum) for enum in enums)})
|
||||
|
||||
fmt_keys.update(
|
||||
{"{}_toctree".format(k): "\n ".join("{}".format(enum) for enum in enums)})
|
||||
|
||||
# noinspection PyShadowingBuiltins
|
||||
for enum in enums:
|
||||
with open(root + "/{}.rst".format(enum), "w") as f2:
|
||||
title = "{}".format(enum)
|
||||
|
||||
f2.write(title + "\n" + "=" * len(title) + "\n\n")
|
||||
f2.write(".. autoclass:: pyrogram.enums.{}()".format(enum))
|
||||
f2.write("\n :members:\n")
|
||||
|
||||
f2.write("\n.. raw:: html\n :file: ./cleanup.html\n")
|
||||
|
||||
f.write(template.format(**fmt_keys))
|
||||
|
||||
|
||||
def start():
|
||||
global page_template
|
||||
global toctree
|
||||
|
21
compiler/docs/template/enums.rst
vendored
Normal file
21
compiler/docs/template/enums.rst
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
Enumerations
|
||||
============
|
||||
|
||||
This page is about Pyrogram enumerations.
|
||||
Enumerations are types that hold a group of related values to be used whenever a constant value is required.
|
||||
They will help you deal with those values in a type-safe way and also enable code completion so that you can be sure
|
||||
to apply only a valid value among the expected ones.
|
||||
|
||||
-----
|
||||
|
||||
.. currentmodule:: pyrogram.enums
|
||||
|
||||
.. autosummary::
|
||||
:nosignatures:
|
||||
|
||||
{enums_hlist}
|
||||
|
||||
.. toctree::
|
||||
:hidden:
|
||||
|
||||
{enums_toctree}
|
Loading…
Reference in New Issue
Block a user