Skip to content

Commit f1406ae

Browse files
committed
docstring updates
1 parent 0a29799 commit f1406ae

File tree

2 files changed

+61
-17
lines changed

2 files changed

+61
-17
lines changed

.scripts/process_markdown.py

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,59 @@
88
# Add more mappings as needed
99
}
1010

11-
def print_specific_anchor_targets(content):
12-
"""Print the anchor targets extracted from the first line after specific headings that begin with four hash marks (####), which begins with a dash, and save the content of the line along with the matched heading pattern."""
11+
def add_anchor_tags(content):
12+
"""Process the parameters block of text as specified, including 'Setter Methods' and 'Execution Methods'.
13+
Insert <a href="#"> before and </a> after lines that start with a dash (-)."""
1314
lines = content.split('\n')
14-
specific_headings = ['#### Setter Methods', '#### Execution Methods', '#### Methods', '#### Generated By']
15-
line_content = ""
15+
processed_lines = []
16+
processing = False
17+
found_first_dash = False # Variable to track the first dash
1618

17-
for i, line in enumerate(lines):
18-
if line.strip() in specific_headings:
19-
matched_heading = line.strip() # Save the matched heading pattern
20-
for j in range(i+1, len(lines)):
21-
if lines[j].strip().startswith('-'):
22-
line_content = lines[j].strip() # Save the entire line content
23-
# Extract the text between the first backtick ` and the first open parenthesis (
24-
match = re.search(r"`(.*?)\(", lines[j])
25-
if match:
26-
anchor_target = match.group(1).strip() # Strip out any whitespace
27-
print(f"Matched Heading: {matched_heading}, Anchor Target: {anchor_target}, Line Content: {line_content}")
28-
break # Move to the next heading after processing
19+
for line in lines:
20+
if (match := line.strip()) in ['#### Setter Methods', '#### Execution Methods', '#### Methods', '#### Generated By']:
21+
processing = True
22+
matched_string = match # Keep track of which string matched
23+
found_first_dash = False # Reset for each new section
24+
processed_lines.append(line)
25+
continue
26+
if processing:
27+
if not found_first_dash:
28+
if line.strip() == '':
29+
processed_lines.append(line)
30+
continue
31+
elif not line.lstrip().startswith('-'):
32+
processed_lines.append(line)
33+
continue
34+
else:
35+
found_first_dash = True # Found the first dash, start processing lines
36+
if line.startswith('-'):
37+
if matched_string != '#### Generated By':
38+
previous_lines = lines[:lines.index(line)]
39+
type_word = ""
40+
for prev_line in reversed(previous_lines):
41+
if prev_line.strip().startswith("type "):
42+
type_word = prev_line.split()[1]
43+
break
44+
anchor = line[line.find('`')+1:line.find('(')].strip()
45+
# Insert <a href="#"> before and </a> after the line
46+
processed_lines.append('- ' + f'<a href="#{type_word}.{anchor}">' +'`' + line[3:] + '</a>')
47+
else:
48+
anchor = line[line.find('`')+1:line.find('(')].strip()
49+
# Insert <a href="#"> before and </a> after the line
50+
processed_lines.append(f'<a href="#{anchor}">')
51+
processed_lines.append(line)
52+
processed_lines.append('</a>') # Ensure an additional new line after closing tag for better readability
53+
elif line.strip() == '' or line.startswith(' '):
54+
processed_lines.append(line)
55+
continue
56+
else:
57+
# Stop processing if the line does not start with a dash
58+
processing = False
59+
processed_lines.append(line)
60+
else:
61+
processed_lines.append(line)
62+
63+
return '\n'.join(processed_lines)
2964

3065
def move_all_struct_definitions(content):
3166
"""Move all struct definition blocks right after their type documentation."""
@@ -240,7 +275,7 @@ def process_file(file_path, patterns, replacements):
240275
content = remove_index_block(content) # Remove index block
241276
content = correct_escaping_in_links(content) # Correct escaping in links
242277
content = move_all_struct_definitions(content) # Move all struct definitions
243-
print_specific_anchor_targets(content)
278+
content = add_anchor_tags(content)
244279
# content = add_anchor_tags_to_generated_by(content) # Add anchor tags to 'Generated By' sections
245280

246281
write_file_content(file_path, content)

indices_candles.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
// Package client includes types and methods to access the Index Candles endpoint.
2+
//
3+
// # Making Index Candle Requests
4+
//
5+
// Get historical price candles for an index. Use [IndicesCandlesRequest] to make requests to the endpoint using any of the three supported execution methods:
6+
//
7+
// 1. [IndicesCandlesRequest.Get] returns a slice of [models.Candle].
8+
// 2. [IndicesCandlesRequest.Packed] will generate a [models.IndicesCandlesResponse] which can then be unpacked using the [models.IndicesCandlesResponse.Unpack] method into [models.Candle].
9+
// 3. [IndicesCandlesRequest.Raw] will give you access to the raw resty.Response and you can access the raw JSON or the [http.Response] using any of the Resty library's methods.
110
package client
211

312
import (

0 commit comments

Comments
 (0)