Skip to main content

pypawn-annotation

Python библиотека, реализует автоматическую аннотацию для функций из языка программирования pawn.

  • Установка последней версии модуля
pip install pypawn-annotations
  • Пример использования модуля. Аннотация к native функции:
import pypawn_annotations

function = pypawn_annotations.PawnFunction(
    string="native bool: function(const iUser, const str: szLogin[32], const str: szPassword[32]);"
)

annotation = pypawn_annotations.Annotation(
    function=function, description=f'Description: this function authorizes the user'
)

print(annotation.show())
  • Результат выполнения кода
/* 
 * Description: function
 * 
 * @param const int:iUser            iUser
 * @param const str:szLogin[32]      szLogin[32]
 * @param const str:szPassword[32]   szPassword[32]
 * @return                           bool: 
 */

Структура объекта PawnFunction

  • Модуль использует регулярные выражения для поиска групп.
  1. Title: string - ключевое слово, обозначающее что строка является функцией (native, forward, func)

  2. General tag: tuple - основной тэг функции, который содержит в себе два элемента:

    • enum объект класса AnnotationTags

    • название тэга

  3. Name: string - имя функции

  4. Args: list[dict] - массив словарей каждый из которых содержит в себе четыре ключа:

    • qualifier: tuple - квалификатор, enum объект класса AnnotationQualifier

    • tag: tuple - работает по принципу general tag

    • name: string - имя аргумента

  • Вывод в консоль. Cтруктура объекта PawnFunction:
[0] string: native bool: function(const iUser, const str: szLogin[32], const str: szPassword[32]);
[1] title: native
[2] general_tag: (<AnnotationTags.TAG_CUSTOM: 4>, 'bool:')
[3] name: function
[4] args: [{'qualifier': <AnnotationQualifier.QUALIFIER_CONST: 1>, 'tag': (<AnnotationTags.TAG_INT: 0>, 'int'), 'name': 'iUser', 'description': 'iUser'}, {'qualifier': <AnnotationQualifier.QUALIFIER_CONST: 1>, 'tag': (<AnnotationTags.TAG_STR: 2>, 'str'), 'name': 'szLogin[32]', 'description': 'szLogin[32]'}, {'qualifier': <AnnotationQualifier.QUALIFIER_CONST: 1>, 'tag': (<AnnotationTags.TAG_STR: 2>, 'str'), 'name': 'szPassword[32]', 'description': 'szPassword[32]'}]
[5] is_title_tag_function: False
[6] is_title_tag_forward: False
[7] is_title_tag_native: True
[8] flags: 15
  • Базовые параметры функций:
functions: tuple = (
	"native global_tag: function_name(tag: name = value)",
	"forward global_tag: function_name(tag: name = value)",
	"func global_tag: function_name(tag: name = value)"

	"native global_tag: function_name(const tag: name = value)",
	"forward global_tag: function_name(const tag: name = value)",
	"func global_tag: function_name(const tag: name = value)"
)
  • Поддержка Венгерской нотации об именовании переменных, для автоматического определения тегов
functions: tuple = (
	"func global_tag: function_name(iHungarianNotation = value)", 
	"func global_tag: function_name(flHungarianNotation = value)",
	"func global_tag: function_name(szHungarianNotation = value)",
	"func global_tag: function_name(bHungarianNotation = value)"
)

Больше примеров здесь:

https://github.com/bonkibon-education/pypawn-annotations-examples

Metadata

Release files for pypawn-annotations 1.0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pypawn-annotations 1.0.0.2
File Size Uploaded
pypawn_annotations-1.0.0.2.tar.gz 19.1 kB Details

Release files / pypawn_annotations-1.0.0.2.tar.gz

Download URL pypawn_annotations-1.0.0.2.tar.gz
Size 19.1 kB
Tags Source
SHA-256 checksum
How to use checksums
13d37c5ef3a63f2e04b847747d3be43f16ea46a6b4f4d80c303dae26fbc6dfc7
BLAKE2b-256 checksum
How to use checksums
66df69866d9edb2ffd0d0ed5eab7d3f0a681c15ab14e088e1985b3ebba1b3d3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.11

Release history Release notifications | RSS feed

This release

1.0.0.2 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page