Skip to content

Commit 10472e7

Browse files
Add categories to doc specs (#313)
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
1 parent fb38447 commit 10472e7

File tree

5 files changed

+36
-13
lines changed

5 files changed

+36
-13
lines changed

bin/docs_scripts/doc_constant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Documentation generation metadata
88
DOCUMENTATION_METADATA = {
9-
"hogRef": "0.2",
9+
"hogRef": "0.3",
1010
"slugPrefix": "posthog-python",
1111
"specUrl": "https://github.com/PostHog/posthog-python",
1212
}

bin/docs_scripts/generate_json_schemas.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,14 @@ def generate_sdk_documentation():
377377
except Exception as e:
378378
print(f"Error analyzing type {name}: {e}")
379379

380+
# Clean types of empty types
381+
382+
# Remove types that have no properties and no examples
383+
# Remove types that have no properties and no examples
384+
types_list = [
385+
t for t in types_list if len(t["properties"]) > 0 or t["example"] != ""
386+
]
387+
380388
# Collect classes
381389
classes_list = []
382390

@@ -419,13 +427,28 @@ def generate_sdk_documentation():
419427
}
420428
)
421429

430+
# Collect categories from functions
431+
categories = ["Initialization", "Identification", "Capture"]
432+
seen_categories = set(categories)
433+
for class_info in classes_list:
434+
if "functions" in class_info:
435+
for func in class_info["functions"]:
436+
if (
437+
"category" in func
438+
and func["category"] not in seen_categories
439+
and func["category"]
440+
):
441+
categories.append(func["category"])
442+
seen_categories.add(func["category"])
443+
422444
# Create the final structure
423445
result = {
424446
"id": "posthog-python",
425447
"hogRef": DOCUMENTATION_METADATA["hogRef"],
426448
"info": sdk_info,
427449
"types": types_list,
428450
"classes": classes_list,
451+
"categories": categories,
429452
}
430453

431454
return result

posthog/ai/anthropic/anthropic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import time
1010
import uuid
11-
from typing import Any, Dict, Optional, cast
11+
from typing import Any, Dict, Optional
1212

1313
from posthog.ai.utils import (
1414
call_llm_and_track_usage,

posthog/ai/openai/openai_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import time
22
import uuid
3-
from typing import Any, Dict, List, Optional, cast
3+
from typing import Any, Dict, List, Optional
44

55
try:
66
import openai

posthog/client.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def get_feature_variants(
329329
only these flags will be evaluated, improving performance.
330330
331331
Category:
332-
Feature Flags
332+
Feature flags
333333
"""
334334
resp_data = self.get_flags_decision(
335335
distinct_id,
@@ -368,7 +368,7 @@ def get_feature_payloads(
368368
```
369369
370370
Category:
371-
Feature Flags
371+
Feature flags
372372
"""
373373
resp_data = self.get_flags_decision(
374374
distinct_id,
@@ -407,7 +407,7 @@ def get_feature_flags_and_payloads(
407407
```
408408
409409
Category:
410-
Feature Flags
410+
Feature flags
411411
"""
412412
resp = self.get_flags_decision(
413413
distinct_id,
@@ -446,7 +446,7 @@ def get_flags_decision(
446446
```
447447
448448
Category:
449-
Feature Flags
449+
Feature flags
450450
"""
451451
groups = groups or {}
452452
person_properties = person_properties or {}
@@ -1169,7 +1169,7 @@ def load_feature_flags(self):
11691169
```
11701170
11711171
Category:
1172-
Feature Flags
1172+
Feature flags
11731173
"""
11741174
if not self.personal_api_key:
11751175
self.log.warning(
@@ -1291,7 +1291,7 @@ def feature_enabled(
12911291
```
12921292
12931293
Category:
1294-
Feature Flags
1294+
Feature flags
12951295
"""
12961296
response = self.get_feature_flag(
12971297
key,
@@ -1499,7 +1499,7 @@ def get_feature_flag(
14991499
```
15001500
15011501
Category:
1502-
Feature Flags
1502+
Feature flags
15031503
"""
15041504
feature_flag_result = self.get_feature_flag_result(
15051505
key,
@@ -1589,7 +1589,7 @@ def get_feature_flag_payload(
15891589
```
15901590
15911591
Category:
1592-
Feature Flags
1592+
Feature flags
15931593
"""
15941594
feature_flag_result = self._get_feature_flag_result(
15951595
key,
@@ -1759,7 +1759,7 @@ def get_all_flags(
17591759
```
17601760
17611761
Category:
1762-
Feature Flags
1762+
Feature flags
17631763
"""
17641764
response = self.get_all_flags_and_payloads(
17651765
distinct_id,
@@ -1803,7 +1803,7 @@ def get_all_flags_and_payloads(
18031803
```
18041804
18051805
Category:
1806-
Feature Flags
1806+
Feature flags
18071807
"""
18081808
if self.disabled:
18091809
return {"featureFlags": None, "featureFlagPayloads": None}

0 commit comments

Comments
 (0)