|
| 1 | +""" |
| 2 | +Constants for PostHog Python SDK documentation generation. |
| 3 | +""" |
| 4 | + |
| 5 | +from typing import Dict, Union |
| 6 | + |
| 7 | +# Types that are built-in to Python and don't need to be documented |
| 8 | +NO_DOCS_TYPES = [ |
| 9 | + "Client", |
| 10 | + "any", |
| 11 | + "int", |
| 12 | + "float", |
| 13 | + "bool", |
| 14 | + "dict", |
| 15 | + "list", |
| 16 | + "str", |
| 17 | + "tuple", |
| 18 | + "set", |
| 19 | + "frozenset", |
| 20 | + "bytes", |
| 21 | + "bytearray", |
| 22 | + "memoryview", |
| 23 | + "range", |
| 24 | + "slice", |
| 25 | + "complex", |
| 26 | + "Union", |
| 27 | + "Optional", |
| 28 | + "Any", |
| 29 | + "Callable", |
| 30 | + "Type", |
| 31 | + "TypeVar", |
| 32 | + "Generic", |
| 33 | + "Literal", |
| 34 | + "ClassVar", |
| 35 | + "Final", |
| 36 | + "Annotated", |
| 37 | + "NotRequired", |
| 38 | + "Required", |
| 39 | + "None", |
| 40 | + "NoneType", |
| 41 | + "object", |
| 42 | + "Unpack", |
| 43 | + "BaseException", |
| 44 | + "Exception", |
| 45 | +] |
| 46 | + |
| 47 | +# Documentation generation metadata |
| 48 | +DOCUMENTATION_METADATA = { |
| 49 | + "hogRef": "0.1", |
| 50 | + "slugPrefix": "posthog-python", |
| 51 | + "specUrl": "https://github.com/PostHog/posthog-python", |
| 52 | +} |
| 53 | + |
| 54 | +# Docstring parsing patterns for new format |
| 55 | +DOCSTRING_PATTERNS = { |
| 56 | + "examples_section": r"Examples:\s*\n(.*?)(?=\n\s*\n\s*Category:|\Z)", |
| 57 | + "args_section": r"Args:\s*\n(.*?)(?=\n\s*\n\s*Examples:|\n\s*\n\s*Details:|\n\s*\n\s*Category:|\Z)", |
| 58 | + "details_section": r"Details:\s*\n(.*?)(?=\n\s*\n\s*Examples:|\n\s*\n\s*Category:|\Z)", |
| 59 | + "category_section": r"Category:\s*\n\s*(.+?)\s*(?:\n|$)", |
| 60 | + "code_block": r"```(?:python)?\n(.*?)```", |
| 61 | + "param_description": r"^\s*{param_name}:\s*(.+?)(?=\n\s*\w+:|\Z)", |
| 62 | + "args_marker": r"\n\s*Args:\s*\n", |
| 63 | + "examples_marker": r"\n\s*Examples:\s*\n", |
| 64 | + "details_marker": r"\n\s*Details:\s*\n", |
| 65 | + "category_marker": r"\n\s*Category:\s*\n", |
| 66 | +} |
| 67 | + |
| 68 | +# Output file configuration |
| 69 | +OUTPUT_CONFIG: Dict[str, Union[str, int]] = { |
| 70 | + "output_dir": ".", |
| 71 | + "filename": "posthog-python-references.json", |
| 72 | + "indent": 2, |
| 73 | +} |
| 74 | + |
| 75 | +# Documentation structure defaults |
| 76 | +DOC_DEFAULTS = { |
| 77 | + "showDocs": True, |
| 78 | + "releaseTag": "public", |
| 79 | + "return_type_void": "None", |
| 80 | + "max_optional_params": 3, |
| 81 | +} |
0 commit comments