Skip to content

Commit

Permalink
docstring updates
Browse files Browse the repository at this point in the history
  • Loading branch information
MarketDataApp committed Feb 14, 2024
1 parent 0a29799 commit f1406ae
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 17 deletions.
69 changes: 52 additions & 17 deletions .scripts/process_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,59 @@
# Add more mappings as needed
}

def print_specific_anchor_targets(content):
"""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."""
def add_anchor_tags(content):
"""Process the parameters block of text as specified, including 'Setter Methods' and 'Execution Methods'.
Insert <a href="#"> before and </a> after lines that start with a dash (-)."""
lines = content.split('\n')
specific_headings = ['#### Setter Methods', '#### Execution Methods', '#### Methods', '#### Generated By']
line_content = ""
processed_lines = []
processing = False
found_first_dash = False # Variable to track the first dash

for i, line in enumerate(lines):
if line.strip() in specific_headings:
matched_heading = line.strip() # Save the matched heading pattern
for j in range(i+1, len(lines)):
if lines[j].strip().startswith('-'):
line_content = lines[j].strip() # Save the entire line content
# Extract the text between the first backtick ` and the first open parenthesis (
match = re.search(r"`(.*?)\(", lines[j])
if match:
anchor_target = match.group(1).strip() # Strip out any whitespace
print(f"Matched Heading: {matched_heading}, Anchor Target: {anchor_target}, Line Content: {line_content}")
break # Move to the next heading after processing
for line in lines:
if (match := line.strip()) in ['#### Setter Methods', '#### Execution Methods', '#### Methods', '#### Generated By']:
processing = True
matched_string = match # Keep track of which string matched
found_first_dash = False # Reset for each new section
processed_lines.append(line)
continue
if processing:
if not found_first_dash:
if line.strip() == '':
processed_lines.append(line)
continue
elif not line.lstrip().startswith('-'):
processed_lines.append(line)
continue
else:
found_first_dash = True # Found the first dash, start processing lines
if line.startswith('-'):
if matched_string != '#### Generated By':
previous_lines = lines[:lines.index(line)]
type_word = ""
for prev_line in reversed(previous_lines):
if prev_line.strip().startswith("type "):
type_word = prev_line.split()[1]
break
anchor = line[line.find('`')+1:line.find('(')].strip()
# Insert <a href="#"> before and </a> after the line
processed_lines.append('- ' + f'<a href="#{type_word}.{anchor}">' +'`' + line[3:] + '</a>')
else:
anchor = line[line.find('`')+1:line.find('(')].strip()
# Insert <a href="#"> before and </a> after the line
processed_lines.append(f'<a href="#{anchor}">')
processed_lines.append(line)
processed_lines.append('</a>') # Ensure an additional new line after closing tag for better readability
elif line.strip() == '' or line.startswith(' '):
processed_lines.append(line)
continue
else:
# Stop processing if the line does not start with a dash
processing = False
processed_lines.append(line)
else:
processed_lines.append(line)

return '\n'.join(processed_lines)

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

write_file_content(file_path, content)
Expand Down
9 changes: 9 additions & 0 deletions indices_candles.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
// Package client includes types and methods to access the Index Candles endpoint.
//
// # Making Index Candle Requests
//
// Get historical price candles for an index. Use [IndicesCandlesRequest] to make requests to the endpoint using any of the three supported execution methods:
//
// 1. [IndicesCandlesRequest.Get] returns a slice of [models.Candle].
// 2. [IndicesCandlesRequest.Packed] will generate a [models.IndicesCandlesResponse] which can then be unpacked using the [models.IndicesCandlesResponse.Unpack] method into [models.Candle].
// 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.
package client

import (
Expand Down

0 comments on commit f1406ae

Please sign in to comment.