Skip to content

Commit

Permalink
removed md client as optional param
Browse files Browse the repository at this point in the history
  • Loading branch information
MarketDataApp committed Feb 17, 2024
1 parent bab0149 commit 0214a46
Show file tree
Hide file tree
Showing 22 changed files with 432 additions and 698 deletions.
36 changes: 26 additions & 10 deletions .scripts/gomarkdoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ DEST_DIR="${SRC_DIR}/../documentation/sdk/go/"
# Function to move and merge the 'go' directory to the destination directory
move_and_merge_go_dir() {
SOURCE_DIR="$OUTPUT_DIR/go" # Assuming the 'go' folder is directly inside the OUTPUT_DIR

# Use rsync to copy files from source to destination.
rsync -av --remove-source-files "$SOURCE_DIR/" "$DEST_DIR/"

if [ "$PERFORM_CLEANUP" = true ]; then
# Use rsync to copy files from source to destination and remove the source files.
rsync -av --remove-source-files "$SOURCE_DIR/" "$DEST_DIR/"
else
# Use rsync to copy files from source to destination without removing the source files.
rsync -av "$SOURCE_DIR/" "$DEST_DIR/"
fi
# Find and remove empty directories in the source directory
find "$SOURCE_DIR" -type d -empty -delete

Expand All @@ -58,16 +61,12 @@ process_group() {
# Remove the word "bulk" from the group name if it exists
MODEL_GROUP_NAME=${GROUP_NAME/bulk/}

MAIN_FILE="${GROUP_NAME}.go"
TEST_FILE="${GROUP_NAME}_test.go"
MODEL_MAIN_FILE="$MODELS_DIR/${MODEL_GROUP_NAME}.go"
MODEL_TEST_FILE="$MODELS_DIR/${MODEL_GROUP_NAME}_test.go"
fi

MAIN_FILE="${GROUP_NAME}.go"
TEST_FILE="${GROUP_NAME}_test.go"
MODEL_MAIN_FILE="$MODELS_DIR/${MODEL_GROUP_NAME}.go"
MODEL_TEST_FILE="$MODELS_DIR/${MODEL_GROUP_NAME}_test.go"
CANDLE_FILE="$MODELS_DIR/candle.go" # Path to the candle.go file
CANDLE_TEST_FILE="$MODELS_DIR/candle_test.go" # Path to the candle.go file

Expand All @@ -76,25 +75,39 @@ process_group() {
TMP_DIR=$(create_tmp_dir)
echo "Using temporary directory for main files: $TMP_DIR"

MAIN_FILES_COPIED=false

if [ -f "$SRC_DIR/$MAIN_FILE" ]; then
echo "Copying file: $SRC_DIR/$MAIN_FILE to $TMP_DIR"
cp "$SRC_DIR/$MAIN_FILE" "$TMP_DIR"
MAIN_FILES_COPIED=true
fi
if [ -f "$SRC_DIR/$TEST_FILE" ]; then
echo "Copying file: $SRC_DIR/$TEST_FILE to $TMP_DIR"
cp "$SRC_DIR/$TEST_FILE" "$TMP_DIR"
MAIN_FILES_COPIED=true
fi
if [ "$MAIN_FILES_COPIED" = true ]; then
gomarkdoc --output "$OUTPUT_DIR/${GROUP_NAME}_request.md" "$TMP_DIR"
fi
gomarkdoc --output "$OUTPUT_DIR/${GROUP_NAME}_request.md" "$TMP_DIR"

rm -rf "$TMP_DIR"

# Documentation for model files
TMP_DIR=$(create_tmp_dir)
echo "Using new temporary directory for model files: $TMP_DIR"

MODEL_FILES_COPIED=false

if [ -f "$SRC_DIR/$MODEL_MAIN_FILE" ]; then
echo "Copying file: $SRC_DIR/$MODEL_MAIN_FILE to $TMP_DIR"
cp "$SRC_DIR/$MODEL_MAIN_FILE" "$TMP_DIR"
MODEL_FILES_COPIED=true
fi
if [ -f "$SRC_DIR/$MODEL_TEST_FILE" ]; then
echo "Copying file: $SRC_DIR/$MODEL_TEST_FILE to $TMP_DIR"
cp "$SRC_DIR/$MODEL_TEST_FILE" "$TMP_DIR"
MODEL_FILES_COPIED=true
fi
# Check if the group name contains "candles" and copy candle.go if it does
if [[ "$GROUP_NAME" == *"candles"* ]]; then
Expand All @@ -107,7 +120,9 @@ process_group() {
fi
fi

gomarkdoc --output "$OUTPUT_DIR/${GROUP_NAME}_response.md" "$TMP_DIR"
if [ "$MODEL_FILES_COPIED" = true ]; then
gomarkdoc --output "$OUTPUT_DIR/${GROUP_NAME}_response.md" "$TMP_DIR"
fi

# Clean up temporary directory
rm -rf "$TMP_DIR"
Expand Down Expand Up @@ -139,6 +154,7 @@ process_group "options_lookup"
process_group "options_quotes"
process_group "options_strikes"
process_group "options_chain"
process_group "client"



Expand Down
13 changes: 11 additions & 2 deletions .scripts/process_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"https://www.marketdata.app/docs/api/options/strikes": {"title": "Strikes", "sidebar_position": 3},
"https://www.marketdata.app/docs/api/options/chain": {"title": "Option Chain", "sidebar_position": 4},
"https://www.marketdata.app/docs/api/options/quotes": {"title": "Quotes", "sidebar_position": 5},
"https://www.marketdata.app/docs/sdk/go/client": {"title": "Client", "sidebar_position": 3},

# Add more mappings as needed
}
Expand Down Expand Up @@ -611,8 +612,16 @@ def combine_files_into_mdx(file_paths):
if info:
header_text = f"---\ntitle: {info['title']}\nsidebar_position: {info['sidebar_position']}\n---\n\n"
combined_content = header_text + combined_content
path_after_api = url.split("/api")[-1]
output_filename = f"go{path_after_api}.mdx"
# Use consistent logic for both /api/ and /sdk/
if "/sdk/" in url:
base_name = "go"
path_after_segment = url.split("/sdk/")[-1]
elif "/api/" in url:
base_name = "go"
path_after_segment = url.split("/api/")[-1]
else:
continue # Skip if URL does not contain /api/ or /sdk/
output_filename = f"{base_name}/{path_after_segment}.mdx"
break # Exit the loop after processing the first matching URL

if "<Tabs>" in combined_content:
Expand Down
42 changes: 41 additions & 1 deletion baseRequest.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
// Package client provides a Go SDK for interacting with the Market Data API.
// It includes functionality for making API requests, handling responses,
// managing rate limits, and logging. The SDK supports various data types
// including stocks, options, and market status information.
//
// # Usage
//
// To use the SDK, you first need to create an instance of MarketDataClient
// using the GetClient function. This client will then be used to make
// API requests to the Market Data API.
//
// # Example
//
// client := GetClient()
// client.Debug(true) // Enable debug mode to log detailed request and response information
// quote, err := client.StockQuotes().Symbol("AAPL").Get()
//
// # Authentication
//
// The SDK uses an API token for authentication. The token can be set as an
// environment variable (MARKETDATA_TOKEN) or directly in your code. However,
// storing tokens in your code is not recommended for security reasons.
//
// # Rate Limiting
//
// The MarketDataClient automatically tracks and manages the API's rate limits.
// You can check if the rate limit has been exceeded with the RateLimitExceeded method.
//
// # Logging
//
// The SDK logs all unsuccessful (400-499 and 500-599) responses to specific log files
// based on the response status code. Successful responses (200-299) are logged when
// debug mode is enabled. Logs include detailed information such as request and response
// headers, response status code, and the response body.
//
// # Debug Mode
//
// Debug mode can be enabled by calling the Debug method on the MarketDataClient instance.
// When enabled, the SDK will log detailed information about each request and response,
// which is useful for troubleshooting.
package client

import (
Expand Down Expand Up @@ -233,6 +273,6 @@ func (request *baseRequest) Raw(optionalClients ...*MarketDataClient) (*resty.Re
return nil, fmt.Errorf("MarketDataClient is nil")
}

response, err := request.client.GetRawResponse(request)
response, err := request.client.getRawResponse(request)
return response, err
}
Loading

0 comments on commit 0214a46

Please sign in to comment.