80
80
LibraryArgumentDefinition ,
81
81
NativeValue ,
82
82
SourceEntity ,
83
+ cached_method ,
83
84
single_call ,
84
85
)
85
86
@@ -362,7 +363,8 @@ def __hash__(self) -> int:
362
363
)
363
364
)
364
365
365
- def to_markdown (self , header_level : int = 2 ) -> str :
366
+ @cached_method
367
+ def to_markdown (self , header_level : int = 2 , only_doc : bool = False ) -> str :
366
368
result = ""
367
369
368
370
result += f"##{ '#' * header_level } { self .name } ({ self .type } )\n \n "
@@ -378,19 +380,22 @@ def to_markdown(self, header_level: int = 2) -> str:
378
380
else :
379
381
result += self .doc
380
382
381
- if self .members :
382
- result += f"\n \n ###{ '#' * header_level } Allowed Values:\n \n "
383
- result += "- " + "\n - " .join (f"`{ m .name } `" for m in self .members )
384
-
385
- if self .items :
386
- result += f"\n \n ###{ '#' * header_level } Dictionary Structure:\n \n "
387
- result += "```\n {"
388
- result += "\n " .join (f"'{ m .key } ': <{ m .type } > { '# optional' if not m .required else '' } " for m in self .items )
389
- result += "\n }\n ```"
383
+ if not only_doc :
384
+ if self .members :
385
+ result += f"\n \n ###{ '#' * header_level } Allowed Values:\n \n "
386
+ result += "- " + "\n - " .join (f"`{ m .name } `" for m in self .members )
387
+
388
+ if self .items :
389
+ result += f"\n \n ###{ '#' * header_level } Dictionary Structure:\n \n "
390
+ result += "```\n {"
391
+ result += "\n " .join (
392
+ f"'{ m .key } ': <{ m .type } > { '# optional' if not m .required else '' } " for m in self .items
393
+ )
394
+ result += "\n }\n ```"
390
395
391
- if self .accepts :
392
- result += f"\n \n ###{ '#' * header_level } Converted Types:\n \n "
393
- result += "- " + "\n - " .join (self .accepts )
396
+ if self .accepts :
397
+ result += f"\n \n ###{ '#' * header_level } Converted Types:\n \n "
398
+ result += "- " + "\n - " .join (self .accepts )
394
399
395
400
return result
396
401
@@ -475,6 +480,7 @@ def from_robot(arg: Any) -> ArgumentInfo:
475
480
def __str__ (self ) -> str :
476
481
return self .signature ()
477
482
483
+ @cached_method
478
484
def signature (self , add_types : bool = True ) -> str :
479
485
prefix = ""
480
486
if self .kind == KeywordArgumentKind .POSITIONAL_ONLY_MARKER :
@@ -721,6 +727,7 @@ def range(self) -> Range:
721
727
),
722
728
)
723
729
730
+ @cached_method
724
731
def to_markdown (
725
732
self ,
726
733
add_signature : bool = True ,
@@ -796,7 +803,7 @@ def escape_pipe(s: str) -> str:
796
803
797
804
result += (
798
805
f"\n | `{ prefix } { a .name !s} `"
799
- f' | { ": " if a .types else " " } '
806
+ f" | { ': ' if a .types else ' ' } "
800
807
f"{ escaped_pipe .join (f'`{ escape_pipe (s )} `' for s in a .types ) if a .types else '' } "
801
808
f"| { '=' if a .default_value is not None else '' } "
802
809
f"| { f'`{ a .default_value !s} `' if a .default_value else '' } |"
@@ -832,6 +839,7 @@ def signature(self) -> str:
832
839
+ ")"
833
840
)
834
841
842
+ @cached_method
835
843
def parameter_signature (self , full_signatures : Optional [Sequence [int ]] = None ) -> str :
836
844
return (
837
845
"("
@@ -1094,6 +1102,7 @@ def range(self) -> Range:
1094
1102
),
1095
1103
)
1096
1104
1105
+ @cached_method
1097
1106
def to_markdown (
1098
1107
self ,
1099
1108
add_signature : bool = True ,
@@ -1250,6 +1259,7 @@ class VariablesDoc(LibraryDoc):
1250
1259
1251
1260
variables : List [ImportedVariableDefinition ] = field (default_factory = list )
1252
1261
1262
+ @cached_method
1253
1263
def to_markdown (
1254
1264
self ,
1255
1265
add_signature : bool = True ,
0 commit comments