IncludeCPP 4.3.0__py3-none-any.whl → 4.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- includecpp/CHANGELOG.md +22 -0
- includecpp/__init__.py +1 -1
- includecpp/__init__.pyi +1 -4
- includecpp/cli/commands.py +1218 -25
- includecpp/core/cpp_api_extensions.pyi +204 -200
- includecpp/core/cssl/__init__.py +317 -0
- includecpp/core/cssl/cpp/build/api.pyd +0 -0
- includecpp/core/cssl/cpp/build/cssl_core.pyi +323 -0
- includecpp/core/cssl/cpp/build/libgcc_s_seh-1.dll +0 -0
- includecpp/core/cssl/cpp/build/libstdc++-6.dll +0 -0
- includecpp/core/cssl/cpp/build/libwinpthread-1.dll +0 -0
- includecpp/core/cssl/cpp/cssl_core.cp +108 -0
- includecpp/core/cssl/cpp/cssl_lexer.hpp +280 -0
- includecpp/core/cssl/cssl_builtins.py +142 -27
- includecpp/core/cssl/cssl_compiler.py +448 -0
- includecpp/core/cssl/cssl_optimizer.py +833 -0
- includecpp/core/cssl/cssl_parser.py +433 -38
- includecpp/core/cssl/cssl_runtime.py +294 -15
- includecpp/core/cssl/cssl_syntax.py +17 -0
- includecpp/core/cssl/cssl_types.py +143 -11
- includecpp/core/cssl_bridge.py +39 -2
- includecpp/generator/parser.cpp +38 -14
- includecpp/vscode/cssl/package.json +15 -0
- includecpp/vscode/cssl/syntaxes/cssl.tmLanguage.json +96 -0
- {includecpp-4.3.0.dist-info → includecpp-4.6.0.dist-info}/METADATA +1 -1
- {includecpp-4.3.0.dist-info → includecpp-4.6.0.dist-info}/RECORD +30 -21
- {includecpp-4.3.0.dist-info → includecpp-4.6.0.dist-info}/WHEEL +0 -0
- {includecpp-4.3.0.dist-info → includecpp-4.6.0.dist-info}/entry_points.txt +0 -0
- {includecpp-4.3.0.dist-info → includecpp-4.6.0.dist-info}/licenses/LICENSE +0 -0
- {includecpp-4.3.0.dist-info → includecpp-4.6.0.dist-info}/top_level.txt +0 -0
includecpp/cli/commands.py
CHANGED
|
@@ -16,6 +16,36 @@ from .config_parser import CppProjectConfig
|
|
|
16
16
|
colorama_init()
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
def _preprocess_doc_option():
|
|
20
|
+
"""
|
|
21
|
+
Preprocess sys.argv to handle --doc with optional value.
|
|
22
|
+
Converts: --doc (alone) -> --doc ""
|
|
23
|
+
Keeps: --doc "term" -> --doc "term"
|
|
24
|
+
"""
|
|
25
|
+
args = sys.argv[:]
|
|
26
|
+
new_args = []
|
|
27
|
+
i = 0
|
|
28
|
+
while i < len(args):
|
|
29
|
+
arg = args[i]
|
|
30
|
+
if arg == '--doc':
|
|
31
|
+
new_args.append(arg)
|
|
32
|
+
# Check if next arg exists and is not another option
|
|
33
|
+
if i + 1 < len(args) and not args[i + 1].startswith('-'):
|
|
34
|
+
new_args.append(args[i + 1])
|
|
35
|
+
i += 1
|
|
36
|
+
else:
|
|
37
|
+
# No value provided - add empty string
|
|
38
|
+
new_args.append('')
|
|
39
|
+
else:
|
|
40
|
+
new_args.append(arg)
|
|
41
|
+
i += 1
|
|
42
|
+
sys.argv[:] = new_args
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# Preprocess before Click parses arguments
|
|
46
|
+
_preprocess_doc_option()
|
|
47
|
+
|
|
48
|
+
|
|
19
49
|
def _is_experimental_enabled() -> bool:
|
|
20
50
|
"""Check if experimental features (cppy, ai) are enabled."""
|
|
21
51
|
config_path = Path.home() / '.includecpp' / '.secret'
|
|
@@ -262,15 +292,48 @@ def _show_changelog(count: int = 2, show_all: bool = False):
|
|
|
262
292
|
|
|
263
293
|
|
|
264
294
|
def _get_doc_path():
|
|
265
|
-
"""Get path to DOCUMENTATION.md file."""
|
|
295
|
+
"""Get path to README.md or DOCUMENTATION.md file."""
|
|
266
296
|
package_dir = Path(__file__).parent.parent
|
|
297
|
+
|
|
298
|
+
# 1. Check if running from development (project root has README.md)
|
|
299
|
+
project_root = package_dir.parent
|
|
300
|
+
readme_path = project_root / 'README.md'
|
|
301
|
+
if readme_path.exists() and (project_root / 'pyproject.toml').exists():
|
|
302
|
+
# We're in development mode - use project README
|
|
303
|
+
return readme_path
|
|
304
|
+
|
|
305
|
+
# 2. DOCUMENTATION.md in package (installed package)
|
|
267
306
|
doc_path = package_dir / 'DOCUMENTATION.md'
|
|
268
307
|
if doc_path.exists():
|
|
269
308
|
return doc_path
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
309
|
+
|
|
310
|
+
# 3. README.md in package dir
|
|
311
|
+
readme_pkg = package_dir / 'README.md'
|
|
312
|
+
if readme_pkg.exists():
|
|
313
|
+
return readme_pkg
|
|
314
|
+
|
|
315
|
+
# 4. Try current working directory
|
|
316
|
+
cwd_readme = Path.cwd() / 'README.md'
|
|
317
|
+
if cwd_readme.exists():
|
|
318
|
+
return cwd_readme
|
|
319
|
+
cwd_doc = Path.cwd() / 'DOCUMENTATION.md'
|
|
320
|
+
if cwd_doc.exists():
|
|
321
|
+
return cwd_doc
|
|
322
|
+
|
|
323
|
+
# 5. Try using importlib.resources for installed package
|
|
324
|
+
try:
|
|
325
|
+
import importlib.resources as pkg_resources
|
|
326
|
+
try:
|
|
327
|
+
# Python 3.9+
|
|
328
|
+
files = pkg_resources.files('includecpp')
|
|
329
|
+
doc_file = files / 'DOCUMENTATION.md'
|
|
330
|
+
if doc_file.is_file():
|
|
331
|
+
return Path(str(doc_file))
|
|
332
|
+
except Exception:
|
|
333
|
+
pass
|
|
334
|
+
except ImportError:
|
|
335
|
+
pass
|
|
336
|
+
|
|
274
337
|
return None
|
|
275
338
|
|
|
276
339
|
|
|
@@ -368,7 +431,8 @@ def _show_doc(search_term: str = None):
|
|
|
368
431
|
|
|
369
432
|
|
|
370
433
|
@click.group(invoke_without_command=True)
|
|
371
|
-
@click.option('--doc', 'doc_search',
|
|
434
|
+
@click.option('--doc', 'doc_search', default=None, help='Show documentation. Use --doc or --doc "term" to search.')
|
|
435
|
+
@click.option('-d', 'doc_flag', is_flag=True, help='Show full documentation (shorthand)')
|
|
372
436
|
@click.option('--changelog', 'show_changelog', is_flag=True, help='Show changelog (last 2 releases by default)')
|
|
373
437
|
@click.option('--all', 'changelog_all', is_flag=True, help='Show all changelog entries (use with --changelog)')
|
|
374
438
|
@click.option('--1', 'changelog_1', is_flag=True, hidden=True)
|
|
@@ -382,7 +446,7 @@ def _show_doc(search_term: str = None):
|
|
|
382
446
|
@click.option('--9', 'changelog_9', is_flag=True, hidden=True)
|
|
383
447
|
@click.option('--10', 'changelog_10', is_flag=True, hidden=True)
|
|
384
448
|
@click.pass_context
|
|
385
|
-
def cli(ctx, doc_search, show_changelog, changelog_all, changelog_1, changelog_2, changelog_3,
|
|
449
|
+
def cli(ctx, doc_search, doc_flag, show_changelog, changelog_all, changelog_1, changelog_2, changelog_3,
|
|
386
450
|
changelog_4, changelog_5, changelog_6, changelog_7, changelog_8, changelog_9, changelog_10):
|
|
387
451
|
"""IncludeCPP - C++ Performance in Python, Zero Hassle
|
|
388
452
|
|
|
@@ -418,9 +482,10 @@ def cli(ctx, doc_search, show_changelog, changelog_all, changelog_1, changelog_2
|
|
|
418
482
|
_show_changelog(count=count)
|
|
419
483
|
ctx.exit(0)
|
|
420
484
|
|
|
421
|
-
# Handle documentation - --doc or
|
|
422
|
-
if doc_search is not None:
|
|
423
|
-
|
|
485
|
+
# Handle documentation - --doc "search" or -d (flag)
|
|
486
|
+
if doc_search is not None or doc_flag:
|
|
487
|
+
# Empty string from --doc without value should show full docs (like None)
|
|
488
|
+
search_term = doc_search if doc_search else None
|
|
424
489
|
_show_doc(search_term)
|
|
425
490
|
ctx.exit(0)
|
|
426
491
|
|
|
@@ -2630,7 +2695,8 @@ def plugin(plugin_name, files, private):
|
|
|
2630
2695
|
method_regex = re.compile(
|
|
2631
2696
|
r'(?:(?:virtual|static|inline|explicit|constexpr)\s+)*' # Optional modifiers
|
|
2632
2697
|
r'(?:const\s+)?' # Optional const before return type
|
|
2633
|
-
r'(
|
|
2698
|
+
r'((?:(?:unsigned|signed|long|short)\s+)*' # v4.3.2: Handle multi-word types (unsigned long long, etc.)
|
|
2699
|
+
r'[a-zA-Z_][\w:]*(?:<[^<>]*(?:<[^<>]*>[^<>]*)*>)?(?:\s*[&*])?)\s+' # Return type (handles nested templates)
|
|
2634
2700
|
r'(\w+)\s*' # Method name
|
|
2635
2701
|
r'\(([^)]*)\)\s*' # Parameters (captured in group 3)
|
|
2636
2702
|
r'(const)?' # Const qualifier after params (captured in group 4)
|
|
@@ -7737,26 +7803,1082 @@ def cssl_makemodule(path, output):
|
|
|
7737
7803
|
click.echo(f" Type: {module_data['type']}")
|
|
7738
7804
|
|
|
7739
7805
|
|
|
7806
|
+
# ============================================================================
|
|
7807
|
+
# CSSL Documentation Category Helpers
|
|
7808
|
+
# ============================================================================
|
|
7809
|
+
|
|
7810
|
+
def _show_doc_categories():
|
|
7811
|
+
"""Show overview of all CSSL syntax categories."""
|
|
7812
|
+
click.secho("CSSL Syntax Categories", fg='cyan', bold=True)
|
|
7813
|
+
click.secho("=" * 60, fg='cyan')
|
|
7814
|
+
click.echo()
|
|
7815
|
+
|
|
7816
|
+
categories = [
|
|
7817
|
+
("--snapshots, -s", "%", "Captured variable snapshots", "yellow"),
|
|
7818
|
+
("--references, -r", "&", "Function/variable references", "green"),
|
|
7819
|
+
("--overrides, -o", "++, embedded, &<>", "Override/replacement syntax", "magenta"),
|
|
7820
|
+
("--datatypes, -t", "string, int, ...", "Data types", "blue"),
|
|
7821
|
+
("--keywords, -k", "if, for, class, ...", "All keywords", "cyan"),
|
|
7822
|
+
("--operators", "<==, <<==, +, ...", "All operators", "yellow"),
|
|
7823
|
+
("--containers, -c", "stack<T>, vector<T>, ...", "Container types", "green"),
|
|
7824
|
+
("--globals", "@, global", "Global variables", "magenta"),
|
|
7825
|
+
("--injection, -i", "<==, <<==, +<==", "Code injection", "red"),
|
|
7826
|
+
("--open", "open, OpenFind", "Open parameters", "blue"),
|
|
7827
|
+
("--embedded, -e", "embedded", "Function/class replacement", "magenta"),
|
|
7828
|
+
("--classes", "class, extends, ...", "OOP syntax", "cyan"),
|
|
7829
|
+
("--enums", "enum, Enum::Value", "Enumerated types", "yellow"),
|
|
7830
|
+
("--exceptions, -x", "try, catch, throw", "Exception handling", "red"),
|
|
7831
|
+
("--modifiers, -m", "const, private, ...", "Access/type modifiers", "blue"),
|
|
7832
|
+
("--builtins, -b", "printl, json::, ...", "Built-in functions", "green"),
|
|
7833
|
+
]
|
|
7834
|
+
|
|
7835
|
+
for flag, symbols, desc, color in categories:
|
|
7836
|
+
click.echo(f" {click.style(flag, fg=color, bold=True):30} ", nl=False)
|
|
7837
|
+
click.echo(f"{click.style(symbols, fg='white'):25} ", nl=False)
|
|
7838
|
+
click.echo(f"{desc}")
|
|
7839
|
+
|
|
7840
|
+
click.echo()
|
|
7841
|
+
click.secho("Usage:", fg='cyan')
|
|
7842
|
+
click.echo(" includecpp cssl doc --snapshots # Show % documentation")
|
|
7843
|
+
click.echo(" includecpp cssl doc --embedded # Show embedded docs")
|
|
7844
|
+
click.echo(" includecpp cssl doc \"keyword\" # Search documentation")
|
|
7845
|
+
|
|
7846
|
+
|
|
7847
|
+
def _show_doc_snapshots():
|
|
7848
|
+
"""Show % snapshot syntax documentation."""
|
|
7849
|
+
click.secho("% - Captured Variable Snapshots", fg='yellow', bold=True)
|
|
7850
|
+
click.secho("=" * 60, fg='yellow')
|
|
7851
|
+
click.echo()
|
|
7852
|
+
|
|
7853
|
+
click.secho("Description:", fg='cyan')
|
|
7854
|
+
click.echo(" The % prefix captures the current value of a variable or function")
|
|
7855
|
+
click.echo(" at definition time. Used in embedded functions to preserve the")
|
|
7856
|
+
click.echo(" original function before replacement.")
|
|
7857
|
+
click.echo()
|
|
7858
|
+
|
|
7859
|
+
click.secho("Syntax:", fg='cyan')
|
|
7860
|
+
click.echo(" %variable - Captured value of 'variable'")
|
|
7861
|
+
click.echo(" %function() - Call the original function (before embedding)")
|
|
7862
|
+
click.echo()
|
|
7863
|
+
|
|
7864
|
+
click.secho("Examples:", fg='cyan')
|
|
7865
|
+
click.echo()
|
|
7866
|
+
click.secho(" // In embedded function, call original:", fg='white')
|
|
7867
|
+
click.echo(" embedded define MyPrint(text) &print {")
|
|
7868
|
+
click.echo(" %print(\"[LOG] \" + text); // Call original print")
|
|
7869
|
+
click.echo(" }")
|
|
7870
|
+
click.echo()
|
|
7871
|
+
click.secho(" // Capture variable value:", fg='white')
|
|
7872
|
+
click.echo(" x = 10;")
|
|
7873
|
+
click.echo(" define test() {")
|
|
7874
|
+
click.echo(" captured = %x; // Captures current value of x")
|
|
7875
|
+
click.echo(" }")
|
|
7876
|
+
click.echo()
|
|
7877
|
+
|
|
7878
|
+
click.secho("Use Cases:", fg='cyan')
|
|
7879
|
+
click.echo(" - Wrapping built-in functions with logging")
|
|
7880
|
+
click.echo(" - Preserving original behavior while adding functionality")
|
|
7881
|
+
click.echo(" - Creating function decorators/middleware")
|
|
7882
|
+
|
|
7883
|
+
|
|
7884
|
+
def _show_doc_references():
|
|
7885
|
+
"""Show & reference syntax documentation."""
|
|
7886
|
+
click.secho("& - References", fg='green', bold=True)
|
|
7887
|
+
click.secho("=" * 60, fg='green')
|
|
7888
|
+
click.echo()
|
|
7889
|
+
|
|
7890
|
+
click.secho("Description:", fg='cyan')
|
|
7891
|
+
click.echo(" The & prefix creates references to functions, variables, or")
|
|
7892
|
+
click.echo(" specifies the function being replaced in embedded definitions.")
|
|
7893
|
+
click.echo()
|
|
7894
|
+
|
|
7895
|
+
click.secho("Syntax:", fg='cyan')
|
|
7896
|
+
click.echo(" &function - Reference to function (for embedded)")
|
|
7897
|
+
click.echo(" &variable - Reference to variable")
|
|
7898
|
+
click.echo(" &ClassName - Reference to class")
|
|
7899
|
+
click.echo(" &$PyObject - Reference to Python object")
|
|
7900
|
+
click.echo()
|
|
7901
|
+
|
|
7902
|
+
click.secho("Examples:", fg='cyan')
|
|
7903
|
+
click.echo()
|
|
7904
|
+
click.secho(" // Embedded function replacement:", fg='white')
|
|
7905
|
+
click.echo(" embedded define Logger(msg) &printl {")
|
|
7906
|
+
click.echo(" %printl(\"[\" + timestamp() + \"] \" + msg);")
|
|
7907
|
+
click.echo(" }")
|
|
7908
|
+
click.echo()
|
|
7909
|
+
click.secho(" // Function reference:", fg='white')
|
|
7910
|
+
click.echo(" callback = &myFunction;")
|
|
7911
|
+
click.echo(" callback(); // Calls myFunction")
|
|
7912
|
+
click.echo()
|
|
7913
|
+
click.secho(" // In open param switch conditions:", fg='white')
|
|
7914
|
+
click.echo(" switch(Params) {")
|
|
7915
|
+
click.echo(" case error & !text: // error exists AND text doesn't")
|
|
7916
|
+
click.echo(" handleError();")
|
|
7917
|
+
click.echo(" }")
|
|
7918
|
+
|
|
7919
|
+
|
|
7920
|
+
def _show_doc_overrides():
|
|
7921
|
+
"""Show override/replacement syntax documentation."""
|
|
7922
|
+
click.secho("Overrides - ++, embedded, &<>", fg='magenta', bold=True)
|
|
7923
|
+
click.secho("=" * 60, fg='magenta')
|
|
7924
|
+
click.echo()
|
|
7925
|
+
|
|
7926
|
+
click.secho("1. embedded - Function/Class Replacement", fg='cyan')
|
|
7927
|
+
click.echo("-" * 40)
|
|
7928
|
+
click.echo(" Replaces an existing function or class with a new implementation.")
|
|
7929
|
+
click.echo()
|
|
7930
|
+
click.echo(" Syntax:")
|
|
7931
|
+
click.echo(" embedded define NewName(args) &OldFunc { ... }")
|
|
7932
|
+
click.echo(" embedded class NewClass &OldClass { ... }")
|
|
7933
|
+
click.echo(" embedded NewEnum &OldEnum { ... } // Enum replacement")
|
|
7934
|
+
click.echo()
|
|
7935
|
+
click.echo(" Example:")
|
|
7936
|
+
click.echo(" embedded define SafePrint(text) &print {")
|
|
7937
|
+
click.echo(" if (text != null) {")
|
|
7938
|
+
click.echo(" %print(text); // Call original")
|
|
7939
|
+
click.echo(" }")
|
|
7940
|
+
click.echo(" }")
|
|
7941
|
+
click.echo()
|
|
7942
|
+
|
|
7943
|
+
click.secho("2. ++ - Constructor/Method Extension", fg='cyan')
|
|
7944
|
+
click.echo("-" * 40)
|
|
7945
|
+
click.echo(" Appends code to existing constructors or methods.")
|
|
7946
|
+
click.echo()
|
|
7947
|
+
click.echo(" Syntax:")
|
|
7948
|
+
click.echo(" ClassName::constr ++ { additional code }")
|
|
7949
|
+
click.echo(" ClassName::method ++ { additional code }")
|
|
7950
|
+
click.echo()
|
|
7951
|
+
click.echo(" Example:")
|
|
7952
|
+
click.echo(" Player::constr ++ {")
|
|
7953
|
+
click.echo(" this->initialized = true;")
|
|
7954
|
+
click.echo(" printl(\"Player created!\");")
|
|
7955
|
+
click.echo(" }")
|
|
7956
|
+
click.echo()
|
|
7957
|
+
|
|
7958
|
+
click.secho("3. open embedded define - Open Parameter Wrapper", fg='cyan')
|
|
7959
|
+
click.echo("-" * 40)
|
|
7960
|
+
click.echo(" Create wrapper with flexible open parameters.")
|
|
7961
|
+
click.echo()
|
|
7962
|
+
click.echo(" Syntax:")
|
|
7963
|
+
click.echo(" open embedded define Name(open Params) &target { ... }")
|
|
7964
|
+
click.echo(" embedded open define Name(open Params) &target { ... }")
|
|
7965
|
+
click.echo()
|
|
7966
|
+
click.echo(" Example:")
|
|
7967
|
+
click.echo(" open embedded define SmartPrint(open Args) &printl {")
|
|
7968
|
+
click.echo(" text = OpenFind<string>(0);")
|
|
7969
|
+
click.echo(" error = OpenFind<string, \"error\">;")
|
|
7970
|
+
click.echo(" switch(Args) {")
|
|
7971
|
+
click.echo(" case error: %printl(\"ERROR: \" + error);")
|
|
7972
|
+
click.echo(" default: %printl(text);")
|
|
7973
|
+
click.echo(" }")
|
|
7974
|
+
click.echo(" }")
|
|
7975
|
+
|
|
7976
|
+
|
|
7977
|
+
def _show_doc_datatypes():
|
|
7978
|
+
"""Show data types documentation."""
|
|
7979
|
+
click.secho("Data Types", fg='blue', bold=True)
|
|
7980
|
+
click.secho("=" * 60, fg='blue')
|
|
7981
|
+
click.echo()
|
|
7982
|
+
|
|
7983
|
+
click.secho("Primitive Types:", fg='cyan')
|
|
7984
|
+
click.echo(" string - Text strings: \"hello\", 'world'")
|
|
7985
|
+
click.echo(" int - Integers: 42, -10, 0x1F")
|
|
7986
|
+
click.echo(" float - Floating point: 3.14, -0.5")
|
|
7987
|
+
click.echo(" bool - Boolean: true, false")
|
|
7988
|
+
click.echo(" null - Null value: null, None")
|
|
7989
|
+
click.echo(" dynamic - Any type (type inference)")
|
|
7990
|
+
click.echo(" void - No return value (functions)")
|
|
7991
|
+
click.echo()
|
|
7992
|
+
|
|
7993
|
+
click.secho("Container Types:", fg='cyan')
|
|
7994
|
+
click.echo(" array<T> - Fixed-size array")
|
|
7995
|
+
click.echo(" list<T> - Dynamic list (alias: vector<T>)")
|
|
7996
|
+
click.echo(" stack<T> - LIFO stack")
|
|
7997
|
+
click.echo(" vector<T> - Dynamic array")
|
|
7998
|
+
click.echo(" map<K,V> - Key-value dictionary")
|
|
7999
|
+
click.echo(" set<T> - Unique elements set")
|
|
8000
|
+
click.echo(" combo<T> - Combination container")
|
|
8001
|
+
click.echo(" iterator<T> - Iterator object")
|
|
8002
|
+
click.echo(" datastruct<T> - Custom data structure")
|
|
8003
|
+
click.echo()
|
|
8004
|
+
|
|
8005
|
+
click.secho("Special Types:", fg='cyan')
|
|
8006
|
+
click.echo(" json - JSON object")
|
|
8007
|
+
click.echo(" regex - Regular expression")
|
|
8008
|
+
click.echo(" callable - Function reference")
|
|
8009
|
+
click.echo(" object - Generic object")
|
|
8010
|
+
click.echo()
|
|
8011
|
+
|
|
8012
|
+
click.secho("Type Declaration:", fg='cyan')
|
|
8013
|
+
click.echo(" string name = \"John\";")
|
|
8014
|
+
click.echo(" int count = 0;")
|
|
8015
|
+
click.echo(" dynamic value = getAny();")
|
|
8016
|
+
click.echo(" list<string> names = [\"a\", \"b\"];")
|
|
8017
|
+
click.echo(" map<string, int> scores = {\"a\": 10};")
|
|
8018
|
+
|
|
8019
|
+
|
|
8020
|
+
def _show_doc_keywords():
|
|
8021
|
+
"""Show all CSSL keywords."""
|
|
8022
|
+
click.secho("CSSL Keywords", fg='cyan', bold=True)
|
|
8023
|
+
click.secho("=" * 60, fg='cyan')
|
|
8024
|
+
click.echo()
|
|
8025
|
+
|
|
8026
|
+
click.secho("Control Flow:", fg='yellow')
|
|
8027
|
+
click.echo(" if, elif, else - Conditionals")
|
|
8028
|
+
click.echo(" for, foreach, while - Loops")
|
|
8029
|
+
click.echo(" switch, case, default - Pattern matching")
|
|
8030
|
+
click.echo(" break, continue - Loop control")
|
|
8031
|
+
click.echo(" return - Function return")
|
|
8032
|
+
click.echo(" try, catch, finally - Exception handling")
|
|
8033
|
+
click.echo(" throw - Raise exception")
|
|
8034
|
+
click.echo()
|
|
8035
|
+
|
|
8036
|
+
click.secho("Functions:", fg='yellow')
|
|
8037
|
+
click.echo(" define - Define function: define name() { }")
|
|
8038
|
+
click.echo(" void - No return type: void name() { }")
|
|
8039
|
+
click.echo(" shuffled - Randomized function")
|
|
8040
|
+
click.echo(" open - Open/variadic parameters")
|
|
8041
|
+
click.echo(" closed - No variadic params")
|
|
8042
|
+
click.echo()
|
|
8043
|
+
|
|
8044
|
+
click.secho("Classes:", fg='yellow')
|
|
8045
|
+
click.echo(" class - Define class: class Name { }")
|
|
8046
|
+
click.echo(" struct - Define struct")
|
|
8047
|
+
click.echo(" enum - Define enum: enum Name { A, B }")
|
|
8048
|
+
click.echo(" interface - Define interface")
|
|
8049
|
+
click.echo(" extends - Inherit from class")
|
|
8050
|
+
click.echo(" overwrites - Override parent class")
|
|
8051
|
+
click.echo(" constr - Constructor")
|
|
8052
|
+
click.echo(" new - Create instance: new ClassName()")
|
|
8053
|
+
click.echo(" this - Current instance reference")
|
|
8054
|
+
click.echo(" super - Parent class reference")
|
|
8055
|
+
click.echo()
|
|
8056
|
+
|
|
8057
|
+
click.secho("Modifiers:", fg='yellow')
|
|
8058
|
+
click.echo(" embedded - Replace existing function/class")
|
|
8059
|
+
click.echo(" global - Global variable declaration")
|
|
8060
|
+
click.echo(" private - Private member")
|
|
8061
|
+
click.echo(" protected - Protected member")
|
|
8062
|
+
click.echo(" public - Public member")
|
|
8063
|
+
click.echo(" static - Static member")
|
|
8064
|
+
click.echo(" const - Constant value")
|
|
8065
|
+
click.echo(" final - Cannot be overridden")
|
|
8066
|
+
click.echo(" virtual - Virtual method")
|
|
8067
|
+
click.echo(" abstract - Abstract class/method")
|
|
8068
|
+
click.echo()
|
|
8069
|
+
|
|
8070
|
+
click.secho("Special:", fg='yellow')
|
|
8071
|
+
click.echo(" payload - Load payload file")
|
|
8072
|
+
click.echo(" include - Include CSSL file")
|
|
8073
|
+
click.echo(" import - Import module")
|
|
8074
|
+
click.echo(" bytearrayed - Multi-return analysis")
|
|
8075
|
+
click.echo(" in - Iteration/membership")
|
|
8076
|
+
click.echo(" range - Number range")
|
|
8077
|
+
|
|
8078
|
+
|
|
8079
|
+
def _show_doc_operators():
|
|
8080
|
+
"""Show all CSSL operators."""
|
|
8081
|
+
click.secho("CSSL Operators", fg='yellow', bold=True)
|
|
8082
|
+
click.secho("=" * 60, fg='yellow')
|
|
8083
|
+
click.echo()
|
|
8084
|
+
|
|
8085
|
+
click.secho("Arithmetic:", fg='cyan')
|
|
8086
|
+
click.echo(" + Addition / String concatenation")
|
|
8087
|
+
click.echo(" - Subtraction")
|
|
8088
|
+
click.echo(" * Multiplication")
|
|
8089
|
+
click.echo(" / Division")
|
|
8090
|
+
click.echo(" % Modulo (also: captured variable prefix)")
|
|
8091
|
+
click.echo(" ** Power/exponentiation")
|
|
8092
|
+
click.echo(" ++ Increment / Constructor extension")
|
|
8093
|
+
click.echo(" -- Decrement")
|
|
8094
|
+
click.echo()
|
|
8095
|
+
|
|
8096
|
+
click.secho("Comparison:", fg='cyan')
|
|
8097
|
+
click.echo(" == Equal")
|
|
8098
|
+
click.echo(" != Not equal")
|
|
8099
|
+
click.echo(" < Less than")
|
|
8100
|
+
click.echo(" > Greater than")
|
|
8101
|
+
click.echo(" <= Less or equal")
|
|
8102
|
+
click.echo(" >= Greater or equal")
|
|
8103
|
+
click.echo()
|
|
8104
|
+
|
|
8105
|
+
click.secho("Logical:", fg='cyan')
|
|
8106
|
+
click.echo(" && Logical AND")
|
|
8107
|
+
click.echo(" || Logical OR")
|
|
8108
|
+
click.echo(" ! Logical NOT")
|
|
8109
|
+
click.echo(" & Bitwise AND / Reference / Param condition AND")
|
|
8110
|
+
click.echo(" | Bitwise OR")
|
|
8111
|
+
click.echo(" not Keyword NOT")
|
|
8112
|
+
click.echo()
|
|
8113
|
+
|
|
8114
|
+
click.secho("Assignment:", fg='cyan')
|
|
8115
|
+
click.echo(" = Assign")
|
|
8116
|
+
click.echo(" += Add and assign")
|
|
8117
|
+
click.echo(" -= Subtract and assign")
|
|
8118
|
+
click.echo(" *= Multiply and assign")
|
|
8119
|
+
click.echo(" /= Divide and assign")
|
|
8120
|
+
click.echo()
|
|
8121
|
+
|
|
8122
|
+
click.secho("Injection/Infusion:", fg='cyan')
|
|
8123
|
+
click.echo(" <== BruteInjection (replace method body)")
|
|
8124
|
+
click.echo(" +<== Append to method body")
|
|
8125
|
+
click.echo(" -<== Prepend to method body")
|
|
8126
|
+
click.echo(" <<== CodeInfusion (replace, preserves context)")
|
|
8127
|
+
click.echo(" +<<== Append with CodeInfusion")
|
|
8128
|
+
click.echo()
|
|
8129
|
+
|
|
8130
|
+
click.secho("Access:", fg='cyan')
|
|
8131
|
+
click.echo(" . Member access: obj.property")
|
|
8132
|
+
click.echo(" -> Member access: this->property")
|
|
8133
|
+
click.echo(" :: Namespace/static: Class::method, json::parse")
|
|
8134
|
+
click.echo(" @ Global variable: @globalVar")
|
|
8135
|
+
click.echo(" $ Shared object: $sharedName")
|
|
8136
|
+
click.echo(" % Captured/snapshot: %originalFunc")
|
|
8137
|
+
click.echo(" & Reference: &function, &variable")
|
|
8138
|
+
click.echo(" #$ Python interop: #$python_var")
|
|
8139
|
+
|
|
8140
|
+
|
|
8141
|
+
def _show_doc_containers():
|
|
8142
|
+
"""Show container types documentation."""
|
|
8143
|
+
click.secho("Container Types", fg='green', bold=True)
|
|
8144
|
+
click.secho("=" * 60, fg='green')
|
|
8145
|
+
click.echo()
|
|
8146
|
+
|
|
8147
|
+
click.secho("stack<T> - LIFO Stack", fg='cyan')
|
|
8148
|
+
click.echo("-" * 30)
|
|
8149
|
+
click.echo(" stack<int> s;")
|
|
8150
|
+
click.echo(" s.push(10);")
|
|
8151
|
+
click.echo(" s.push(20);")
|
|
8152
|
+
click.echo(" x = s.pop(); // 20")
|
|
8153
|
+
click.echo(" y = s.peek(); // 10")
|
|
8154
|
+
click.echo(" n = s.size(); // 1")
|
|
8155
|
+
click.echo()
|
|
8156
|
+
|
|
8157
|
+
click.secho("vector<T> / list<T> - Dynamic Array", fg='cyan')
|
|
8158
|
+
click.echo("-" * 30)
|
|
8159
|
+
click.echo(" vector<string> v = [\"a\", \"b\", \"c\"];")
|
|
8160
|
+
click.echo(" v.push(\"d\");")
|
|
8161
|
+
click.echo(" v.insert(0, \"start\");")
|
|
8162
|
+
click.echo(" x = v[1]; // \"a\"")
|
|
8163
|
+
click.echo(" v.remove(0);")
|
|
8164
|
+
click.echo(" for (item in v) { printl(item); }")
|
|
8165
|
+
click.echo()
|
|
8166
|
+
|
|
8167
|
+
click.secho("map<K,V> - Dictionary", fg='cyan')
|
|
8168
|
+
click.echo("-" * 30)
|
|
8169
|
+
click.echo(" map<string, int> m = {\"score\": 100};")
|
|
8170
|
+
click.echo(" m[\"lives\"] = 3;")
|
|
8171
|
+
click.echo(" m.set(\"level\", 1);")
|
|
8172
|
+
click.echo(" x = m.get(\"score\"); // 100")
|
|
8173
|
+
click.echo(" if (m.has(\"lives\")) { ... }")
|
|
8174
|
+
click.echo(" keys = m.keys();")
|
|
8175
|
+
click.echo(" vals = m.values();")
|
|
8176
|
+
click.echo()
|
|
8177
|
+
|
|
8178
|
+
click.secho("set<T> - Unique Set", fg='cyan')
|
|
8179
|
+
click.echo("-" * 30)
|
|
8180
|
+
click.echo(" set<int> s = {1, 2, 3};")
|
|
8181
|
+
click.echo(" s.add(4);")
|
|
8182
|
+
click.echo(" s.add(2); // No duplicate")
|
|
8183
|
+
click.echo(" if (s.contains(3)) { ... }")
|
|
8184
|
+
click.echo(" s.remove(1);")
|
|
8185
|
+
click.echo()
|
|
8186
|
+
|
|
8187
|
+
click.secho("array<T> - Fixed Array", fg='cyan')
|
|
8188
|
+
click.echo("-" * 30)
|
|
8189
|
+
click.echo(" array<int> a = [1, 2, 3, 4, 5];")
|
|
8190
|
+
click.echo(" x = a[0];")
|
|
8191
|
+
click.echo(" a[2] = 10;")
|
|
8192
|
+
click.echo(" n = a.length();")
|
|
8193
|
+
|
|
8194
|
+
|
|
8195
|
+
def _show_doc_globals():
|
|
8196
|
+
"""Show global variable documentation."""
|
|
8197
|
+
click.secho("@ - Global Variables", fg='magenta', bold=True)
|
|
8198
|
+
click.secho("=" * 60, fg='magenta')
|
|
8199
|
+
click.echo()
|
|
8200
|
+
|
|
8201
|
+
click.secho("Description:", fg='cyan')
|
|
8202
|
+
click.echo(" Global variables are accessible from anywhere in the code.")
|
|
8203
|
+
click.echo(" Declare with 'global' keyword, access with '@' prefix.")
|
|
8204
|
+
click.echo()
|
|
8205
|
+
|
|
8206
|
+
click.secho("Declaration:", fg='cyan')
|
|
8207
|
+
click.echo(" global version = \"1.0.0\";")
|
|
8208
|
+
click.echo(" global config = {\"debug\": true};")
|
|
8209
|
+
click.echo(" global counter = 0;")
|
|
8210
|
+
click.echo()
|
|
8211
|
+
|
|
8212
|
+
click.secho("Access:", fg='cyan')
|
|
8213
|
+
click.echo(" printl(@version); // \"1.0.0\"")
|
|
8214
|
+
click.echo(" @counter = @counter + 1;")
|
|
8215
|
+
click.echo(" if (@config[\"debug\"]) { ... }")
|
|
8216
|
+
click.echo()
|
|
8217
|
+
|
|
8218
|
+
click.secho("In Payloads:", fg='cyan')
|
|
8219
|
+
click.echo(" // file.cssl-pl")
|
|
8220
|
+
click.echo(" global appName = \"MyApp\";")
|
|
8221
|
+
click.echo(" global settings = {")
|
|
8222
|
+
click.echo(" \"theme\": \"dark\",")
|
|
8223
|
+
click.echo(" \"lang\": \"en\"")
|
|
8224
|
+
click.echo(" };")
|
|
8225
|
+
click.echo()
|
|
8226
|
+
click.echo(" // main.cssl")
|
|
8227
|
+
click.echo(" payload(\"file.cssl-pl\");")
|
|
8228
|
+
click.echo(" printl(@appName); // \"MyApp\"")
|
|
8229
|
+
click.echo()
|
|
8230
|
+
|
|
8231
|
+
click.secho("Namespaced Globals:", fg='cyan')
|
|
8232
|
+
click.echo(" payload(\"engine.cssl-pl\", \"Engine\");")
|
|
8233
|
+
click.echo(" printl(@Engine::version);")
|
|
8234
|
+
|
|
8235
|
+
|
|
8236
|
+
def _show_doc_injection():
|
|
8237
|
+
"""Show code injection operators documentation."""
|
|
8238
|
+
click.secho("Code Injection Operators", fg='red', bold=True)
|
|
8239
|
+
click.secho("=" * 60, fg='red')
|
|
8240
|
+
click.echo()
|
|
8241
|
+
|
|
8242
|
+
click.secho("<== BruteInjection (Replace)", fg='cyan')
|
|
8243
|
+
click.echo("-" * 40)
|
|
8244
|
+
click.echo(" Completely replaces a method body.")
|
|
8245
|
+
click.echo()
|
|
8246
|
+
click.echo(" Syntax: ClassName::method <== { new body }")
|
|
8247
|
+
click.echo()
|
|
8248
|
+
click.echo(" Example:")
|
|
8249
|
+
click.echo(" Player::update <== {")
|
|
8250
|
+
click.echo(" // Completely new implementation")
|
|
8251
|
+
click.echo(" this->x += this->speed;")
|
|
8252
|
+
click.echo(" }")
|
|
8253
|
+
click.echo()
|
|
8254
|
+
|
|
8255
|
+
click.secho("+<== BruteInjection (Append)", fg='cyan')
|
|
8256
|
+
click.echo("-" * 40)
|
|
8257
|
+
click.echo(" Appends code to end of existing method.")
|
|
8258
|
+
click.echo()
|
|
8259
|
+
click.echo(" Syntax: ClassName::method +<== { appended code }")
|
|
8260
|
+
click.echo()
|
|
8261
|
+
click.echo(" Example:")
|
|
8262
|
+
click.echo(" Player::update +<== {")
|
|
8263
|
+
click.echo(" // This runs after original update()")
|
|
8264
|
+
click.echo(" this->checkBounds();")
|
|
8265
|
+
click.echo(" }")
|
|
8266
|
+
click.echo()
|
|
8267
|
+
|
|
8268
|
+
click.secho("-<== BruteInjection (Prepend)", fg='cyan')
|
|
8269
|
+
click.echo("-" * 40)
|
|
8270
|
+
click.echo(" Prepends code to start of existing method.")
|
|
8271
|
+
click.echo()
|
|
8272
|
+
click.echo(" Syntax: ClassName::method -<== { prepended code }")
|
|
8273
|
+
click.echo()
|
|
8274
|
+
click.echo(" Example:")
|
|
8275
|
+
click.echo(" Player::update -<== {")
|
|
8276
|
+
click.echo(" // This runs before original update()")
|
|
8277
|
+
click.echo(" this->validateState();")
|
|
8278
|
+
click.echo(" }")
|
|
8279
|
+
click.echo()
|
|
8280
|
+
|
|
8281
|
+
click.secho("<<== CodeInfusion (Contextual Replace)", fg='cyan')
|
|
8282
|
+
click.echo("-" * 40)
|
|
8283
|
+
click.echo(" Like <== but preserves class context (this, super).")
|
|
8284
|
+
click.echo()
|
|
8285
|
+
click.echo(" Syntax: ClassName::method <<== { new body }")
|
|
8286
|
+
click.echo()
|
|
8287
|
+
click.echo(" Example:")
|
|
8288
|
+
click.echo(" Enemy::attack <<== {")
|
|
8289
|
+
click.echo(" // Has access to this-> context")
|
|
8290
|
+
click.echo(" this->damage = this->baseDamage * 2;")
|
|
8291
|
+
click.echo(" super::attack(); // Call parent")
|
|
8292
|
+
click.echo(" }")
|
|
8293
|
+
|
|
8294
|
+
|
|
8295
|
+
def _show_doc_open():
|
|
8296
|
+
"""Show open parameters documentation."""
|
|
8297
|
+
click.secho("open - Open/Variadic Parameters", fg='blue', bold=True)
|
|
8298
|
+
click.secho("=" * 60, fg='blue')
|
|
8299
|
+
click.echo()
|
|
8300
|
+
|
|
8301
|
+
click.secho("Description:", fg='cyan')
|
|
8302
|
+
click.echo(" 'open' allows functions to accept any number/type of arguments.")
|
|
8303
|
+
click.echo(" Use OpenFind to extract values by index or name.")
|
|
8304
|
+
click.echo()
|
|
8305
|
+
|
|
8306
|
+
click.secho("Function Declaration:", fg='cyan')
|
|
8307
|
+
click.echo(" define myFunc(open Params) { ... }")
|
|
8308
|
+
click.echo(" open define wrapper(open Args) &target { ... }")
|
|
8309
|
+
click.echo()
|
|
8310
|
+
|
|
8311
|
+
click.secho("OpenFind - Extract Arguments:", fg='cyan')
|
|
8312
|
+
click.echo("-" * 40)
|
|
8313
|
+
click.echo(" // By index (positional args):")
|
|
8314
|
+
click.echo(" first = OpenFind<string>(0); // 1st arg as string")
|
|
8315
|
+
click.echo(" second = OpenFind<int>(1); // 2nd arg as int")
|
|
8316
|
+
click.echo()
|
|
8317
|
+
click.echo(" // By name (keyword args):")
|
|
8318
|
+
click.echo(" name = OpenFind<string, \"name\">;")
|
|
8319
|
+
click.echo(" count = OpenFind<int, \"count\">;")
|
|
8320
|
+
click.echo()
|
|
8321
|
+
|
|
8322
|
+
click.secho("switch(Params) - Parameter Matching:", fg='cyan')
|
|
8323
|
+
click.echo("-" * 40)
|
|
8324
|
+
click.echo(" switch(Params) {")
|
|
8325
|
+
click.echo(" case error & !text: // error exists, text doesn't")
|
|
8326
|
+
click.echo(" handleError();")
|
|
8327
|
+
click.echo(" break;")
|
|
8328
|
+
click.echo(" case text & !error: // text exists, error doesn't")
|
|
8329
|
+
click.echo(" printl(text);")
|
|
8330
|
+
click.echo(" break;")
|
|
8331
|
+
click.echo(" case name || id: // name OR id exists")
|
|
8332
|
+
click.echo(" lookup();")
|
|
8333
|
+
click.echo(" break;")
|
|
8334
|
+
click.echo(" default:")
|
|
8335
|
+
click.echo(" printl(\"Unknown\");")
|
|
8336
|
+
click.echo(" }")
|
|
8337
|
+
click.echo()
|
|
8338
|
+
|
|
8339
|
+
click.secho("Complete Example:", fg='cyan')
|
|
8340
|
+
click.echo("-" * 40)
|
|
8341
|
+
click.echo(" open embedded define SmartLog(open Input) &printl {")
|
|
8342
|
+
click.echo(" msg = OpenFind<string>(0);")
|
|
8343
|
+
click.echo(" level = OpenFind<string, \"level\">;")
|
|
8344
|
+
click.echo(" switch(Input) {")
|
|
8345
|
+
click.echo(" case level:")
|
|
8346
|
+
click.echo(" %printl(\"[\" + level + \"] \" + msg);")
|
|
8347
|
+
click.echo(" break;")
|
|
8348
|
+
click.echo(" default:")
|
|
8349
|
+
click.echo(" %printl(msg);")
|
|
8350
|
+
click.echo(" }")
|
|
8351
|
+
click.echo(" }")
|
|
8352
|
+
click.echo()
|
|
8353
|
+
click.echo(" // Usage:")
|
|
8354
|
+
click.echo(" printl(\"Hello\"); // Hello")
|
|
8355
|
+
click.echo(" printl(\"Warning!\", level=\"WARN\"); // [WARN] Warning!")
|
|
8356
|
+
|
|
8357
|
+
|
|
8358
|
+
def _show_doc_embedded():
|
|
8359
|
+
"""Show embedded function/class replacement documentation."""
|
|
8360
|
+
click.secho("embedded - Function/Class Replacement", fg='magenta', bold=True)
|
|
8361
|
+
click.secho("=" * 60, fg='magenta')
|
|
8362
|
+
click.echo()
|
|
8363
|
+
|
|
8364
|
+
click.secho("Description:", fg='cyan')
|
|
8365
|
+
click.echo(" 'embedded' replaces an existing function or class definition.")
|
|
8366
|
+
click.echo(" The original can be called via %originalName().")
|
|
8367
|
+
click.echo()
|
|
8368
|
+
|
|
8369
|
+
click.secho("Function Replacement:", fg='cyan')
|
|
8370
|
+
click.echo("-" * 40)
|
|
8371
|
+
click.echo(" embedded define NewImpl(args) &oldFunction {")
|
|
8372
|
+
click.echo(" // Your new implementation")
|
|
8373
|
+
click.echo(" %oldFunction(args); // Call original if needed")
|
|
8374
|
+
click.echo(" }")
|
|
8375
|
+
click.echo()
|
|
8376
|
+
click.echo(" Example - Logging wrapper:")
|
|
8377
|
+
click.echo(" embedded define Logger(msg) &print {")
|
|
8378
|
+
click.echo(" timestamp = now();")
|
|
8379
|
+
click.echo(" %print(\"[\" + timestamp + \"] \" + msg);")
|
|
8380
|
+
click.echo(" }")
|
|
8381
|
+
click.echo(" print(\"Hello\"); // Now prints with timestamp")
|
|
8382
|
+
click.echo()
|
|
8383
|
+
|
|
8384
|
+
click.secho("With Open Parameters:", fg='cyan')
|
|
8385
|
+
click.echo("-" * 40)
|
|
8386
|
+
click.echo(" Both syntaxes work:")
|
|
8387
|
+
click.echo(" open embedded define Name(open P) &target { }")
|
|
8388
|
+
click.echo(" embedded open define Name(open P) &target { }")
|
|
8389
|
+
click.echo()
|
|
8390
|
+
click.echo(" Example:")
|
|
8391
|
+
click.echo(" open embedded define SafeDiv(open Args) &div {")
|
|
8392
|
+
click.echo(" b = OpenFind<int>(1);")
|
|
8393
|
+
click.echo(" if (b == 0) {")
|
|
8394
|
+
click.echo(" return 0; // Prevent division by zero")
|
|
8395
|
+
click.echo(" }")
|
|
8396
|
+
click.echo(" return %div(OpenFind<int>(0), b);")
|
|
8397
|
+
click.echo(" }")
|
|
8398
|
+
click.echo()
|
|
8399
|
+
|
|
8400
|
+
click.secho("Class Replacement:", fg='cyan')
|
|
8401
|
+
click.echo("-" * 40)
|
|
8402
|
+
click.echo(" embedded class NewClass &OldClass {")
|
|
8403
|
+
click.echo(" // New implementation")
|
|
8404
|
+
click.echo(" }")
|
|
8405
|
+
click.echo()
|
|
8406
|
+
|
|
8407
|
+
click.secho("Enum Replacement:", fg='cyan')
|
|
8408
|
+
click.echo("-" * 40)
|
|
8409
|
+
click.echo(" embedded NewColors &Colors {")
|
|
8410
|
+
click.echo(" RED = \"#FF0000\",")
|
|
8411
|
+
click.echo(" GREEN = \"#00FF00\",")
|
|
8412
|
+
click.echo(" BLUE = \"#0000FF\"")
|
|
8413
|
+
click.echo(" }")
|
|
8414
|
+
click.echo()
|
|
8415
|
+
|
|
8416
|
+
click.secho("Use Cases:", fg='cyan')
|
|
8417
|
+
click.echo(" - Add logging/debugging to existing functions")
|
|
8418
|
+
click.echo(" - Add validation/error handling")
|
|
8419
|
+
click.echo(" - Implement middleware/interceptors")
|
|
8420
|
+
click.echo(" - Mock functions for testing")
|
|
8421
|
+
click.echo(" - Extend built-in functions (print, error, etc.)")
|
|
8422
|
+
|
|
8423
|
+
|
|
8424
|
+
def _show_doc_classes():
|
|
8425
|
+
"""Show class/OOP documentation."""
|
|
8426
|
+
click.secho("Classes and OOP", fg='cyan', bold=True)
|
|
8427
|
+
click.secho("=" * 60, fg='cyan')
|
|
8428
|
+
click.echo()
|
|
8429
|
+
|
|
8430
|
+
click.secho("Class Definition:", fg='yellow')
|
|
8431
|
+
click.echo("-" * 40)
|
|
8432
|
+
click.echo(" class Player {")
|
|
8433
|
+
click.echo(" string name;")
|
|
8434
|
+
click.echo(" int health = 100;")
|
|
8435
|
+
click.echo(" int score;")
|
|
8436
|
+
click.echo()
|
|
8437
|
+
click.echo(" constr Player(string n) {")
|
|
8438
|
+
click.echo(" this->name = n;")
|
|
8439
|
+
click.echo(" this->score = 0;")
|
|
8440
|
+
click.echo(" }")
|
|
8441
|
+
click.echo()
|
|
8442
|
+
click.echo(" void takeDamage(int amount) {")
|
|
8443
|
+
click.echo(" this->health -= amount;")
|
|
8444
|
+
click.echo(" }")
|
|
8445
|
+
click.echo(" }")
|
|
8446
|
+
click.echo()
|
|
8447
|
+
|
|
8448
|
+
click.secho("Inheritance (extends):", fg='yellow')
|
|
8449
|
+
click.echo("-" * 40)
|
|
8450
|
+
click.echo(" class Enemy : extends Entity {")
|
|
8451
|
+
click.echo(" int damage;")
|
|
8452
|
+
click.echo()
|
|
8453
|
+
click.echo(" constr Enemy(string name, int dmg) {")
|
|
8454
|
+
click.echo(" super(name); // Call parent constructor")
|
|
8455
|
+
click.echo(" this->damage = dmg;")
|
|
8456
|
+
click.echo(" }")
|
|
8457
|
+
click.echo()
|
|
8458
|
+
click.echo(" void attack(target) {")
|
|
8459
|
+
click.echo(" target.takeDamage(this->damage);")
|
|
8460
|
+
click.echo(" }")
|
|
8461
|
+
click.echo(" }")
|
|
8462
|
+
click.echo()
|
|
8463
|
+
|
|
8464
|
+
click.secho("Override (overwrites):", fg='yellow')
|
|
8465
|
+
click.echo("-" * 40)
|
|
8466
|
+
click.echo(" class Boss : overwrites Enemy {")
|
|
8467
|
+
click.echo(" // Completely replaces Enemy class")
|
|
8468
|
+
click.echo(" int health = 1000;")
|
|
8469
|
+
click.echo()
|
|
8470
|
+
click.echo(" void attack(target) {")
|
|
8471
|
+
click.echo(" // New attack implementation")
|
|
8472
|
+
click.echo(" super::attack(target); // Optional: call parent")
|
|
8473
|
+
click.echo(" target.takeDamage(this->damage * 2);")
|
|
8474
|
+
click.echo(" }")
|
|
8475
|
+
click.echo(" }")
|
|
8476
|
+
click.echo()
|
|
8477
|
+
|
|
8478
|
+
click.secho("Instantiation:", fg='yellow')
|
|
8479
|
+
click.echo("-" * 40)
|
|
8480
|
+
click.echo(" player = new Player(\"Hero\");")
|
|
8481
|
+
click.echo(" enemy = new Enemy(\"Goblin\", 10);")
|
|
8482
|
+
click.echo()
|
|
8483
|
+
click.echo(" // Namespaced class:")
|
|
8484
|
+
click.echo(" engine = new Engine::GameEngine();")
|
|
8485
|
+
click.echo()
|
|
8486
|
+
|
|
8487
|
+
click.secho("Constructor Extension (++):", fg='yellow')
|
|
8488
|
+
click.echo("-" * 40)
|
|
8489
|
+
click.echo(" Player::constr ++ {")
|
|
8490
|
+
click.echo(" // Additional initialization")
|
|
8491
|
+
click.echo(" this->initialized = true;")
|
|
8492
|
+
click.echo(" printl(\"Player \" + this->name + \" created!\");")
|
|
8493
|
+
click.echo(" }")
|
|
8494
|
+
click.echo()
|
|
8495
|
+
|
|
8496
|
+
click.secho("Enums:", fg='yellow')
|
|
8497
|
+
click.echo("-" * 40)
|
|
8498
|
+
click.echo(" enum Direction {")
|
|
8499
|
+
click.echo(" UP = 0,")
|
|
8500
|
+
click.echo(" DOWN = 1,")
|
|
8501
|
+
click.echo(" LEFT = 2,")
|
|
8502
|
+
click.echo(" RIGHT = 3")
|
|
8503
|
+
click.echo(" }")
|
|
8504
|
+
click.echo()
|
|
8505
|
+
click.echo(" dir = Direction.UP;")
|
|
8506
|
+
click.echo(" if (dir == Direction.LEFT) { ... }")
|
|
8507
|
+
|
|
8508
|
+
|
|
8509
|
+
def _show_doc_enums():
|
|
8510
|
+
"""Show enum documentation."""
|
|
8511
|
+
click.secho("Enums - Enumerated Types", fg='yellow', bold=True)
|
|
8512
|
+
click.secho("=" * 60, fg='yellow')
|
|
8513
|
+
click.echo()
|
|
8514
|
+
|
|
8515
|
+
click.secho("Basic Enum Definition:", fg='cyan')
|
|
8516
|
+
click.echo("-" * 40)
|
|
8517
|
+
click.echo(" enum Direction {")
|
|
8518
|
+
click.echo(" UP = 0,")
|
|
8519
|
+
click.echo(" DOWN = 1,")
|
|
8520
|
+
click.echo(" LEFT = 2,")
|
|
8521
|
+
click.echo(" RIGHT = 3")
|
|
8522
|
+
click.echo(" }")
|
|
8523
|
+
click.echo()
|
|
8524
|
+
|
|
8525
|
+
click.secho("Enum Access (EnumName::Value):", fg='cyan')
|
|
8526
|
+
click.echo("-" * 40)
|
|
8527
|
+
click.echo(" dir = Direction::UP;")
|
|
8528
|
+
click.echo(" // or")
|
|
8529
|
+
click.echo(" dir = Direction.UP;")
|
|
8530
|
+
click.echo()
|
|
8531
|
+
click.echo(" if (dir == Direction::LEFT) {")
|
|
8532
|
+
click.echo(" printl(\"Going left!\");")
|
|
8533
|
+
click.echo(" }")
|
|
8534
|
+
click.echo()
|
|
8535
|
+
|
|
8536
|
+
click.secho("String Enums:", fg='cyan')
|
|
8537
|
+
click.echo("-" * 40)
|
|
8538
|
+
click.echo(" enum Colors {")
|
|
8539
|
+
click.echo(" RED = \"#FF0000\",")
|
|
8540
|
+
click.echo(" GREEN = \"#00FF00\",")
|
|
8541
|
+
click.echo(" BLUE = \"#0000FF\"")
|
|
8542
|
+
click.echo(" }")
|
|
8543
|
+
click.echo()
|
|
8544
|
+
click.echo(" color = Colors::RED; // \"#FF0000\"")
|
|
8545
|
+
click.echo()
|
|
8546
|
+
|
|
8547
|
+
click.secho("Embedded Enum Replacement:", fg='cyan')
|
|
8548
|
+
click.echo("-" * 40)
|
|
8549
|
+
click.echo(" // Replace existing enum")
|
|
8550
|
+
click.echo(" embedded NewColors &Colors {")
|
|
8551
|
+
click.echo(" RED = \"crimson\",")
|
|
8552
|
+
click.echo(" GREEN = \"lime\",")
|
|
8553
|
+
click.echo(" BLUE = \"navy\"")
|
|
8554
|
+
click.echo(" }")
|
|
8555
|
+
click.echo()
|
|
8556
|
+
|
|
8557
|
+
click.secho("Enum with Expressions:", fg='cyan')
|
|
8558
|
+
click.echo("-" * 40)
|
|
8559
|
+
click.echo(" base = 100;")
|
|
8560
|
+
click.echo(" enum Scores {")
|
|
8561
|
+
click.echo(" LOW = base,")
|
|
8562
|
+
click.echo(" MEDIUM = base * 2,")
|
|
8563
|
+
click.echo(" HIGH = base * 5")
|
|
8564
|
+
click.echo(" }")
|
|
8565
|
+
click.echo()
|
|
8566
|
+
|
|
8567
|
+
click.secho("Enum Iteration:", fg='cyan')
|
|
8568
|
+
click.echo("-" * 40)
|
|
8569
|
+
click.echo(" for (value in Direction) {")
|
|
8570
|
+
click.echo(" printl(value);")
|
|
8571
|
+
click.echo(" }")
|
|
8572
|
+
|
|
8573
|
+
|
|
8574
|
+
def _show_doc_exceptions():
|
|
8575
|
+
"""Show exception handling documentation."""
|
|
8576
|
+
click.secho("Exception Handling", fg='red', bold=True)
|
|
8577
|
+
click.secho("=" * 60, fg='red')
|
|
8578
|
+
click.echo()
|
|
8579
|
+
|
|
8580
|
+
click.secho("try/catch/finally:", fg='cyan')
|
|
8581
|
+
click.echo("-" * 40)
|
|
8582
|
+
click.echo(" try {")
|
|
8583
|
+
click.echo(" result = riskyOperation();")
|
|
8584
|
+
click.echo(" process(result);")
|
|
8585
|
+
click.echo(" } catch (e) {")
|
|
8586
|
+
click.echo(" printl(\"Error: \" + e);")
|
|
8587
|
+
click.echo(" } finally {")
|
|
8588
|
+
click.echo(" cleanup();")
|
|
8589
|
+
click.echo(" }")
|
|
8590
|
+
click.echo()
|
|
8591
|
+
|
|
8592
|
+
click.secho("except (alias for catch):", fg='cyan')
|
|
8593
|
+
click.echo("-" * 40)
|
|
8594
|
+
click.echo(" try {")
|
|
8595
|
+
click.echo(" data = json::parse(input);")
|
|
8596
|
+
click.echo(" } except (err) {")
|
|
8597
|
+
click.echo(" printl(\"Parse error: \" + err);")
|
|
8598
|
+
click.echo(" data = {};")
|
|
8599
|
+
click.echo(" }")
|
|
8600
|
+
click.echo()
|
|
8601
|
+
|
|
8602
|
+
click.secho("throw - Raise Exception:", fg='cyan')
|
|
8603
|
+
click.echo("-" * 40)
|
|
8604
|
+
click.echo(" define divide(a, b) {")
|
|
8605
|
+
click.echo(" if (b == 0) {")
|
|
8606
|
+
click.echo(" throw \"Division by zero!\";")
|
|
8607
|
+
click.echo(" }")
|
|
8608
|
+
click.echo(" return a / b;")
|
|
8609
|
+
click.echo(" }")
|
|
8610
|
+
click.echo()
|
|
8611
|
+
click.echo(" try {")
|
|
8612
|
+
click.echo(" result = divide(10, 0);")
|
|
8613
|
+
click.echo(" } catch (e) {")
|
|
8614
|
+
click.echo(" printl(e); // \"Division by zero!\"")
|
|
8615
|
+
click.echo(" }")
|
|
8616
|
+
click.echo()
|
|
8617
|
+
|
|
8618
|
+
click.secho("Catching Python Exceptions:", fg='cyan')
|
|
8619
|
+
click.echo("-" * 40)
|
|
8620
|
+
click.echo(" try {")
|
|
8621
|
+
click.echo(" // Python exceptions are also caught")
|
|
8622
|
+
click.echo(" list = [1, 2, 3];")
|
|
8623
|
+
click.echo(" x = list[10]; // IndexError")
|
|
8624
|
+
click.echo(" } catch (e) {")
|
|
8625
|
+
click.echo(" printl(\"Caught: \" + str(e));")
|
|
8626
|
+
click.echo(" }")
|
|
8627
|
+
click.echo()
|
|
8628
|
+
|
|
8629
|
+
click.secho("Nested try/catch:", fg='cyan')
|
|
8630
|
+
click.echo("-" * 40)
|
|
8631
|
+
click.echo(" try {")
|
|
8632
|
+
click.echo(" try {")
|
|
8633
|
+
click.echo(" innerOperation();")
|
|
8634
|
+
click.echo(" } catch (inner) {")
|
|
8635
|
+
click.echo(" throw \"Inner failed: \" + inner;")
|
|
8636
|
+
click.echo(" }")
|
|
8637
|
+
click.echo(" } catch (outer) {")
|
|
8638
|
+
click.echo(" printl(outer);")
|
|
8639
|
+
click.echo(" }")
|
|
8640
|
+
|
|
8641
|
+
|
|
8642
|
+
def _show_doc_modifiers():
|
|
8643
|
+
"""Show modifier keywords documentation."""
|
|
8644
|
+
click.secho("Modifiers - Access and Type Qualifiers", fg='blue', bold=True)
|
|
8645
|
+
click.secho("=" * 60, fg='blue')
|
|
8646
|
+
click.echo()
|
|
8647
|
+
|
|
8648
|
+
click.secho("Access Modifiers:", fg='cyan')
|
|
8649
|
+
click.echo("-" * 40)
|
|
8650
|
+
click.echo(" class MyClass {")
|
|
8651
|
+
click.echo(" private int secret = 42; // Only in class")
|
|
8652
|
+
click.echo(" protected int data = 10; // Class + subclasses")
|
|
8653
|
+
click.echo(" public string name; // Anywhere (default)")
|
|
8654
|
+
click.echo(" }")
|
|
8655
|
+
click.echo()
|
|
8656
|
+
|
|
8657
|
+
click.secho("const - Immutable Values:", fg='cyan')
|
|
8658
|
+
click.echo("-" * 40)
|
|
8659
|
+
click.echo(" const PI = 3.14159;")
|
|
8660
|
+
click.echo(" const MAX_SIZE = 100;")
|
|
8661
|
+
click.echo(" const CONFIG = {\"debug\": true};")
|
|
8662
|
+
click.echo()
|
|
8663
|
+
click.echo(" // Cannot reassign:")
|
|
8664
|
+
click.echo(" PI = 3; // Error!")
|
|
8665
|
+
click.echo()
|
|
8666
|
+
|
|
8667
|
+
click.secho("static - Class-Level Members:", fg='cyan')
|
|
8668
|
+
click.echo("-" * 40)
|
|
8669
|
+
click.echo(" class Counter {")
|
|
8670
|
+
click.echo(" static int count = 0;")
|
|
8671
|
+
click.echo()
|
|
8672
|
+
click.echo(" constr Counter() {")
|
|
8673
|
+
click.echo(" Counter::count += 1;")
|
|
8674
|
+
click.echo(" }")
|
|
8675
|
+
click.echo()
|
|
8676
|
+
click.echo(" static int getCount() {")
|
|
8677
|
+
click.echo(" return Counter::count;")
|
|
8678
|
+
click.echo(" }")
|
|
8679
|
+
click.echo(" }")
|
|
8680
|
+
click.echo()
|
|
8681
|
+
click.echo(" c1 = new Counter();")
|
|
8682
|
+
click.echo(" c2 = new Counter();")
|
|
8683
|
+
click.echo(" printl(Counter::getCount()); // 2")
|
|
8684
|
+
click.echo()
|
|
8685
|
+
|
|
8686
|
+
click.secho("final - Cannot Override:", fg='cyan')
|
|
8687
|
+
click.echo("-" * 40)
|
|
8688
|
+
click.echo(" class Base {")
|
|
8689
|
+
click.echo(" final void important() {")
|
|
8690
|
+
click.echo(" // Cannot be overridden in subclass")
|
|
8691
|
+
click.echo(" }")
|
|
8692
|
+
click.echo(" }")
|
|
8693
|
+
click.echo()
|
|
8694
|
+
|
|
8695
|
+
click.secho("virtual - Override in Subclass:", fg='cyan')
|
|
8696
|
+
click.echo("-" * 40)
|
|
8697
|
+
click.echo(" class Animal {")
|
|
8698
|
+
click.echo(" virtual void speak() {")
|
|
8699
|
+
click.echo(" printl(\"...\");")
|
|
8700
|
+
click.echo(" }")
|
|
8701
|
+
click.echo(" }")
|
|
8702
|
+
click.echo()
|
|
8703
|
+
click.echo(" class Dog : extends Animal {")
|
|
8704
|
+
click.echo(" void speak() {")
|
|
8705
|
+
click.echo(" printl(\"Woof!\");")
|
|
8706
|
+
click.echo(" }")
|
|
8707
|
+
click.echo(" }")
|
|
8708
|
+
click.echo()
|
|
8709
|
+
|
|
8710
|
+
click.secho("abstract - Must Override:", fg='cyan')
|
|
8711
|
+
click.echo("-" * 40)
|
|
8712
|
+
click.echo(" abstract class Shape {")
|
|
8713
|
+
click.echo(" abstract float area(); // Must implement")
|
|
8714
|
+
click.echo(" }")
|
|
8715
|
+
click.echo()
|
|
8716
|
+
click.echo(" class Circle : extends Shape {")
|
|
8717
|
+
click.echo(" float radius;")
|
|
8718
|
+
click.echo(" float area() {")
|
|
8719
|
+
click.echo(" return 3.14 * this->radius * this->radius;")
|
|
8720
|
+
click.echo(" }")
|
|
8721
|
+
click.echo(" }")
|
|
8722
|
+
click.echo()
|
|
8723
|
+
|
|
8724
|
+
click.secho("readonly - Read After Init:", fg='cyan')
|
|
8725
|
+
click.echo("-" * 40)
|
|
8726
|
+
click.echo(" class Config {")
|
|
8727
|
+
click.echo(" readonly string path;")
|
|
8728
|
+
click.echo()
|
|
8729
|
+
click.echo(" constr Config(string p) {")
|
|
8730
|
+
click.echo(" this->path = p; // OK in constructor")
|
|
8731
|
+
click.echo(" }")
|
|
8732
|
+
click.echo(" }")
|
|
8733
|
+
click.echo(" // cfg->path = \"x\"; // Error after construction")
|
|
8734
|
+
|
|
8735
|
+
|
|
8736
|
+
def _show_doc_builtins():
|
|
8737
|
+
"""Show built-in functions documentation."""
|
|
8738
|
+
click.secho("Built-in Functions", fg='green', bold=True)
|
|
8739
|
+
click.secho("=" * 60, fg='green')
|
|
8740
|
+
click.echo()
|
|
8741
|
+
|
|
8742
|
+
click.secho("Output:", fg='cyan')
|
|
8743
|
+
click.echo(" print(x) - Print without newline")
|
|
8744
|
+
click.echo(" printl(x) - Print with newline")
|
|
8745
|
+
click.echo(" error(msg) - Print error message")
|
|
8746
|
+
click.echo(" warn(msg) - Print warning")
|
|
8747
|
+
click.echo(" debug(x) - Debug print")
|
|
8748
|
+
click.echo()
|
|
8749
|
+
|
|
8750
|
+
click.secho("Type Conversion:", fg='cyan')
|
|
8751
|
+
click.echo(" str(x) - Convert to string")
|
|
8752
|
+
click.echo(" int(x) - Convert to integer")
|
|
8753
|
+
click.echo(" float(x) - Convert to float")
|
|
8754
|
+
click.echo(" bool(x) - Convert to boolean")
|
|
8755
|
+
click.echo(" list(x) - Convert to list")
|
|
8756
|
+
click.echo()
|
|
8757
|
+
|
|
8758
|
+
click.secho("String Functions:", fg='cyan')
|
|
8759
|
+
click.echo(" len(s) - Length of string/list")
|
|
8760
|
+
click.echo(" upper(s) - Uppercase")
|
|
8761
|
+
click.echo(" lower(s) - Lowercase")
|
|
8762
|
+
click.echo(" trim(s) - Remove whitespace")
|
|
8763
|
+
click.echo(" split(s, d) - Split by delimiter")
|
|
8764
|
+
click.echo(" join(list, d) - Join with delimiter")
|
|
8765
|
+
click.echo(" replace(s,o,n) - Replace occurrences")
|
|
8766
|
+
click.echo(" substr(s,i,l) - Substring")
|
|
8767
|
+
click.echo(" contains(s,sub) - Check if contains")
|
|
8768
|
+
click.echo(" startswith(s,p) - Check prefix")
|
|
8769
|
+
click.echo(" endswith(s,p) - Check suffix")
|
|
8770
|
+
click.echo()
|
|
8771
|
+
|
|
8772
|
+
click.secho("Math:", fg='cyan')
|
|
8773
|
+
click.echo(" abs(x) - Absolute value")
|
|
8774
|
+
click.echo(" min(a, b) - Minimum")
|
|
8775
|
+
click.echo(" max(a, b) - Maximum")
|
|
8776
|
+
click.echo(" floor(x) - Round down")
|
|
8777
|
+
click.echo(" ceil(x) - Round up")
|
|
8778
|
+
click.echo(" round(x) - Round to nearest")
|
|
8779
|
+
click.echo(" sqrt(x) - Square root")
|
|
8780
|
+
click.echo(" pow(x, y) - Power")
|
|
8781
|
+
click.echo(" random() - Random 0-1")
|
|
8782
|
+
click.echo(" randint(a, b) - Random int in range")
|
|
8783
|
+
click.echo()
|
|
8784
|
+
|
|
8785
|
+
click.secho("Collections:", fg='cyan')
|
|
8786
|
+
click.echo(" len(x) - Length")
|
|
8787
|
+
click.echo(" append(l, x) - Add to list")
|
|
8788
|
+
click.echo(" pop(l) - Remove last")
|
|
8789
|
+
click.echo(" insert(l, i, x) - Insert at index")
|
|
8790
|
+
click.echo(" remove(l, x) - Remove first occurrence")
|
|
8791
|
+
click.echo(" sort(l) - Sort list")
|
|
8792
|
+
click.echo(" reverse(l) - Reverse list")
|
|
8793
|
+
click.echo(" range(a, b) - Number range")
|
|
8794
|
+
click.echo(" keys(m) - Map keys")
|
|
8795
|
+
click.echo(" values(m) - Map values")
|
|
8796
|
+
click.echo()
|
|
8797
|
+
|
|
8798
|
+
click.secho("JSON (json::):", fg='cyan')
|
|
8799
|
+
click.echo(" json::parse(s) - Parse JSON string")
|
|
8800
|
+
click.echo(" json::stringify(x) - Convert to JSON")
|
|
8801
|
+
click.echo(" json::load(path) - Load JSON file")
|
|
8802
|
+
click.echo(" json::save(x,p) - Save to JSON file")
|
|
8803
|
+
click.echo()
|
|
8804
|
+
|
|
8805
|
+
click.secho("File I/O:", fg='cyan')
|
|
8806
|
+
click.echo(" read(path) - Read file contents")
|
|
8807
|
+
click.echo(" write(path, s) - Write to file")
|
|
8808
|
+
click.echo(" append(path, s) - Append to file")
|
|
8809
|
+
click.echo(" exists(path) - Check if file exists")
|
|
8810
|
+
click.echo()
|
|
8811
|
+
|
|
8812
|
+
click.secho("Time:", fg='cyan')
|
|
8813
|
+
click.echo(" now() - Current timestamp")
|
|
8814
|
+
click.echo(" timestamp() - Formatted timestamp")
|
|
8815
|
+
click.echo(" sleep(ms) - Wait milliseconds")
|
|
8816
|
+
click.echo()
|
|
8817
|
+
|
|
8818
|
+
click.secho("Type Checking:", fg='cyan')
|
|
8819
|
+
click.echo(" type(x) - Get type name")
|
|
8820
|
+
click.echo(" isinstance(x,t) - Check instance")
|
|
8821
|
+
click.echo(" isstring(x) - Is string?")
|
|
8822
|
+
click.echo(" isint(x) - Is integer?")
|
|
8823
|
+
click.echo(" islist(x) - Is list?")
|
|
8824
|
+
click.echo(" isnull(x) - Is null?")
|
|
8825
|
+
click.echo(" iscallable(x) - Is function?")
|
|
8826
|
+
|
|
8827
|
+
|
|
7740
8828
|
@cssl.command(name='doc')
|
|
7741
8829
|
@click.argument('search', required=False, default=None)
|
|
7742
8830
|
@click.option('--list', '-l', 'list_sections', is_flag=True, help='List all documentation sections')
|
|
7743
|
-
|
|
8831
|
+
@click.option('--get', '-g', 'show_categories', is_flag=True, help='Show all syntax categories')
|
|
8832
|
+
@click.option('--snapshots', '--snapshot', '-s', 'cat_snapshots', is_flag=True, help='Show % snapshot syntax')
|
|
8833
|
+
@click.option('--references', '--refs', '-r', 'cat_refs', is_flag=True, help='Show & reference syntax')
|
|
8834
|
+
@click.option('--overrides', '--override', '-o', 'cat_overrides', is_flag=True, help='Show ++, embedded, &<> override syntax')
|
|
8835
|
+
@click.option('--datatypes', '--types', '-t', 'cat_types', is_flag=True, help='Show all data types')
|
|
8836
|
+
@click.option('--keywords', '-k', 'cat_keywords', is_flag=True, help='Show all keywords')
|
|
8837
|
+
@click.option('--operators', '--ops', 'cat_operators', is_flag=True, help='Show all operators')
|
|
8838
|
+
@click.option('--containers', '-c', 'cat_containers', is_flag=True, help='Show container types (stack, vector, map)')
|
|
8839
|
+
@click.option('--globals', 'cat_globals', is_flag=True, help='Show @, global syntax')
|
|
8840
|
+
@click.option('--injection', '--inject', '-i', 'cat_injection', is_flag=True, help='Show <==, <<==, +<== injection syntax')
|
|
8841
|
+
@click.option('--open', 'cat_open', is_flag=True, help='Show open parameters and OpenFind')
|
|
8842
|
+
@click.option('--embedded', '-e', 'cat_embedded', is_flag=True, help='Show embedded function/class replacement')
|
|
8843
|
+
@click.option('--classes', 'cat_classes', is_flag=True, help='Show class, extends, overwrites syntax')
|
|
8844
|
+
@click.option('--enums', 'cat_enums', is_flag=True, help='Show enum definitions and EnumName::Value')
|
|
8845
|
+
@click.option('--exceptions', '--except', '-x', 'cat_exceptions', is_flag=True, help='Show try/catch/except/throw')
|
|
8846
|
+
@click.option('--modifiers', '-m', 'cat_modifiers', is_flag=True, help='Show const, private, static, etc.')
|
|
8847
|
+
@click.option('--builtins', '-b', 'cat_builtins', is_flag=True, help='Show built-in functions')
|
|
8848
|
+
def cssl_doc(search, list_sections, show_categories, cat_snapshots, cat_refs, cat_overrides,
|
|
8849
|
+
cat_types, cat_keywords, cat_operators, cat_containers, cat_globals,
|
|
8850
|
+
cat_injection, cat_open, cat_embedded, cat_classes, cat_enums, cat_exceptions,
|
|
8851
|
+
cat_modifiers, cat_builtins):
|
|
7744
8852
|
"""Show CSSL documentation.
|
|
7745
8853
|
|
|
7746
8854
|
\b
|
|
7747
8855
|
Usage:
|
|
7748
8856
|
includecpp cssl doc # Show full documentation
|
|
7749
8857
|
includecpp cssl doc "open" # Search for 'open' keyword
|
|
7750
|
-
includecpp cssl doc
|
|
7751
|
-
includecpp cssl doc
|
|
8858
|
+
includecpp cssl doc --get # Show syntax categories overview
|
|
8859
|
+
includecpp cssl doc --snapshots # Show % snapshot documentation
|
|
8860
|
+
includecpp cssl doc --embedded # Show embedded replacement docs
|
|
7752
8861
|
includecpp cssl doc --list # List all sections
|
|
7753
8862
|
|
|
7754
8863
|
\b
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
8864
|
+
Categories:
|
|
8865
|
+
--get, -g Overview of all syntax categories
|
|
8866
|
+
--snapshots, -s % captured variable snapshots
|
|
8867
|
+
--references, -r & function/variable references
|
|
8868
|
+
--overrides, -o ++, embedded, &<> override syntax
|
|
8869
|
+
--datatypes, -t Data types (string, int, float, bool, ...)
|
|
8870
|
+
--keywords, -k All CSSL keywords
|
|
8871
|
+
--operators All operators (+, -, *, /, <==, <<==, ...)
|
|
8872
|
+
--containers, -c Container types (stack, vector, map, ...)
|
|
8873
|
+
--globals @ global variables
|
|
8874
|
+
--injection, -i Code injection (<==, <<==, +<==)
|
|
8875
|
+
--open open parameters and OpenFind
|
|
8876
|
+
--embedded, -e embedded function/class replacement
|
|
8877
|
+
--classes class, extends, overwrites, constr
|
|
8878
|
+
--enums enum definitions and EnumName::Value
|
|
8879
|
+
--exceptions, -x try/catch/except/throw/finally
|
|
8880
|
+
--modifiers, -m const, private, static, virtual, etc.
|
|
8881
|
+
--builtins, -b Built-in functions (printl, len, json::, ...)
|
|
7760
8882
|
"""
|
|
7761
8883
|
from pathlib import Path as PathLib
|
|
7762
8884
|
import os
|
|
@@ -7792,6 +8914,75 @@ def cssl_doc(search, list_sections):
|
|
|
7792
8914
|
click.echo("Use: includecpp cssl doc \"<keyword>\" to search")
|
|
7793
8915
|
return
|
|
7794
8916
|
|
|
8917
|
+
# Category documentation mode
|
|
8918
|
+
if show_categories:
|
|
8919
|
+
_show_doc_categories()
|
|
8920
|
+
return
|
|
8921
|
+
|
|
8922
|
+
if cat_snapshots:
|
|
8923
|
+
_show_doc_snapshots()
|
|
8924
|
+
return
|
|
8925
|
+
|
|
8926
|
+
if cat_refs:
|
|
8927
|
+
_show_doc_references()
|
|
8928
|
+
return
|
|
8929
|
+
|
|
8930
|
+
if cat_overrides:
|
|
8931
|
+
_show_doc_overrides()
|
|
8932
|
+
return
|
|
8933
|
+
|
|
8934
|
+
if cat_types:
|
|
8935
|
+
_show_doc_datatypes()
|
|
8936
|
+
return
|
|
8937
|
+
|
|
8938
|
+
if cat_keywords:
|
|
8939
|
+
_show_doc_keywords()
|
|
8940
|
+
return
|
|
8941
|
+
|
|
8942
|
+
if cat_operators:
|
|
8943
|
+
_show_doc_operators()
|
|
8944
|
+
return
|
|
8945
|
+
|
|
8946
|
+
if cat_containers:
|
|
8947
|
+
_show_doc_containers()
|
|
8948
|
+
return
|
|
8949
|
+
|
|
8950
|
+
if cat_globals:
|
|
8951
|
+
_show_doc_globals()
|
|
8952
|
+
return
|
|
8953
|
+
|
|
8954
|
+
if cat_injection:
|
|
8955
|
+
_show_doc_injection()
|
|
8956
|
+
return
|
|
8957
|
+
|
|
8958
|
+
if cat_open:
|
|
8959
|
+
_show_doc_open()
|
|
8960
|
+
return
|
|
8961
|
+
|
|
8962
|
+
if cat_embedded:
|
|
8963
|
+
_show_doc_embedded()
|
|
8964
|
+
return
|
|
8965
|
+
|
|
8966
|
+
if cat_classes:
|
|
8967
|
+
_show_doc_classes()
|
|
8968
|
+
return
|
|
8969
|
+
|
|
8970
|
+
if cat_enums:
|
|
8971
|
+
_show_doc_enums()
|
|
8972
|
+
return
|
|
8973
|
+
|
|
8974
|
+
if cat_exceptions:
|
|
8975
|
+
_show_doc_exceptions()
|
|
8976
|
+
return
|
|
8977
|
+
|
|
8978
|
+
if cat_modifiers:
|
|
8979
|
+
_show_doc_modifiers()
|
|
8980
|
+
return
|
|
8981
|
+
|
|
8982
|
+
if cat_builtins:
|
|
8983
|
+
_show_doc_builtins()
|
|
8984
|
+
return
|
|
8985
|
+
|
|
7795
8986
|
# Search mode
|
|
7796
8987
|
if search:
|
|
7797
8988
|
click.secho(f"Searching for: '{search}'", fg='cyan', bold=True)
|
|
@@ -7799,23 +8990,25 @@ def cssl_doc(search, list_sections):
|
|
|
7799
8990
|
click.echo()
|
|
7800
8991
|
|
|
7801
8992
|
# Split into subsections (### headers) for focused results
|
|
7802
|
-
|
|
8993
|
+
# Note: Allow optional leading whitespace since doc may be indented
|
|
8994
|
+
subsections = re.split(r'(?=^\s*### )', content, flags=re.MULTILINE)
|
|
7803
8995
|
|
|
7804
8996
|
# Also split into main sections (## headers)
|
|
7805
|
-
main_sections = re.split(r'(
|
|
8997
|
+
main_sections = re.split(r'(?=^\s*## )', content, flags=re.MULTILINE)
|
|
7806
8998
|
|
|
7807
8999
|
# Find matching subsections (### level) - most focused
|
|
7808
9000
|
matching_subsections = []
|
|
7809
9001
|
for subsection in subsections:
|
|
7810
9002
|
if search.lower() in subsection.lower():
|
|
7811
|
-
# Extract title
|
|
7812
|
-
title_match = re.match(r'
|
|
9003
|
+
# Extract title (allow leading whitespace)
|
|
9004
|
+
title_match = re.match(r'^\s*###\s+(.+)$', subsection, re.MULTILINE)
|
|
7813
9005
|
if title_match:
|
|
7814
9006
|
# Trim subsection to just the content until next ### or ##
|
|
7815
9007
|
lines = subsection.split('\n')
|
|
7816
9008
|
trimmed_lines = []
|
|
7817
9009
|
for line in lines:
|
|
7818
|
-
|
|
9010
|
+
stripped = line.lstrip()
|
|
9011
|
+
if stripped.startswith('## ') and not stripped.startswith('### '):
|
|
7819
9012
|
break
|
|
7820
9013
|
trimmed_lines.append(line)
|
|
7821
9014
|
matching_subsections.append((title_match.group(1), '\n'.join(trimmed_lines)))
|
|
@@ -7853,7 +9046,7 @@ def cssl_doc(search, list_sections):
|
|
|
7853
9046
|
found_sections = []
|
|
7854
9047
|
for section in main_sections:
|
|
7855
9048
|
if search.lower() in section.lower():
|
|
7856
|
-
title_match = re.match(r'
|
|
9049
|
+
title_match = re.match(r'^\s*##\s+(.+)$', section, re.MULTILINE)
|
|
7857
9050
|
if title_match:
|
|
7858
9051
|
found_sections.append((title_match.group(1), section))
|
|
7859
9052
|
|