MCPcopy
hub / github.com/aws/aws-cli / ReSTDocument

Class ReSTDocument

awscli/bcdoc/restdoc.py:23–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21
22
23class ReSTDocument:
24 def __init__(self, target='man'):
25 self.style = ReSTStyle(self)
26 self.target = target
27 self.parser = DocStringParser(self)
28 self.keep_data = True
29 self.do_translation = False
30 self.translation_map = {}
31 self.hrefs = {}
32 self._writes = []
33 self._last_doc_string = None
34
35 def _write(self, s):
36 if self.keep_data and s is not None:
37 self._writes.append(s)
38
39 def write(self, content):
40 """
41 Write content into the document.
42 """
43 self._write(content)
44
45 def writeln(self, content):
46 """
47 Write content on a newline.
48 """
49 self._write('%s%s\n' % (self.style.spaces(), content))
50
51 def peek_write(self):
52 """
53 Returns the last content written to the document without
54 removing it from the stack.
55 """
56 return self._writes[-1]
57
58 def pop_write(self):
59 """
60 Removes and returns the last content written to the stack.
61 """
62 return self._writes.pop()
63
64 def push_write(self, s):
65 """
66 Places new content on the stack.
67 """
68 self._writes.append(s)
69
70 def find_last_write(self, content):
71 """
72 Returns the index of the last occurrence of the content argument
73 in the stack, or returns None if content is not on the stack.
74 """
75 try:
76 return len(self._writes) - self._writes[::-1].index(content) - 1
77 except ValueError:
78 return None
79
80 def insert_write(self, index, content):

Callers 15

create_help_commandMethod · 0.90
create_help_commandMethod · 0.90
test_boldMethod · 0.90
test_empty_boldMethod · 0.90
test_italicsMethod · 0.90
test_empty_italicsMethod · 0.90
test_pMethod · 0.90
test_codeMethod · 0.90
test_empty_codeMethod · 0.90
test_h1Method · 0.90
test_h2Method · 0.90

Calls

no outgoing calls

Tested by 15

create_help_commandMethod · 0.72
create_help_commandMethod · 0.72
test_boldMethod · 0.72
test_empty_boldMethod · 0.72
test_italicsMethod · 0.72
test_empty_italicsMethod · 0.72
test_pMethod · 0.72
test_codeMethod · 0.72
test_empty_codeMethod · 0.72
test_h1Method · 0.72
test_h2Method · 0.72