Skip to content

Commit

Permalink
Made some mkdocs styling fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
senthurayyappan committed Nov 8, 2024
1 parent 6f8f103 commit 7e626a2
Show file tree
Hide file tree
Showing 6 changed files with 385 additions and 312 deletions.
7 changes: 7 additions & 0 deletions docs/models.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Assembly

::: onshape_api.models.assembly

## Document

::: onshape_api.models.document
1 change: 0 additions & 1 deletion docs/modules.md

This file was deleted.

7 changes: 6 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ copyright: Maintained by <a href="https://imsenthur.com">Florian</a>.

nav:
- Home: index.md
- Modules: modules.md
- Models: models.md

plugins:
- search
- mkdocstrings:
Expand All @@ -18,6 +19,7 @@ plugins:
setup_commands:
- import sys
- sys.path.append('../')

theme:
name: material
feature:
Expand Down Expand Up @@ -52,3 +54,6 @@ markdown_extensions:
permalink: true
- pymdownx.arithmatex:
generic: true
- def_list
- pymdownx.tasklist:
custom_checkbox: true
118 changes: 59 additions & 59 deletions onshape_api/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def make_nonce():
Generate a unique ID for the request, 25 chars in length
Returns:
- str: Cryptographic nonce
str: Cryptographic nonce
"""

chars = string.digits + string.ascii_letters
Expand All @@ -81,8 +81,8 @@ class Client:
Provides access to the Onshape REST API.
Attributes:
- env (str, default='./.env'): Location of the environment file
- logging (bool, default=True): Turn logging on or off
env (str, default='./.env'): Location of the environment file
logging (bool, default=True): Turn logging on or off
"""

def __init__(self, env="./.env", log_file="./onshape_api", log_level=1):
Expand All @@ -93,7 +93,7 @@ def __init__(self, env="./.env", log_file="./onshape_api", log_level=1):
you can specify the location of a different file.
Args:
- env (str, default='./.env'): Environment file location
env (str, default='./.env'): Environment file location
"""

self._url = BASE_URL
Expand All @@ -107,10 +107,10 @@ def get_document_metadata(self, did):
Get details for a specified document.
Args:
- did (str): Document ID
did (str): Document ID
Returns:
- requests.Response: Onshape response data
requests.Response: Onshape response data
"""
res = self.request(HTTP.GET, "/api/documents/" + did)
Expand Down Expand Up @@ -142,9 +142,9 @@ def get_elements(self, did, wtype, wid):
Get list of elements in a document.
Args:
- did (str): Document ID
- wtype (str): Workspace type (w, v, or m)
- wid (str): Workspace ID
did (str): Document ID
wtype (str): Workspace type (w, v, or m)
wid (str): Workspace ID
Returns:
-
Expand All @@ -164,12 +164,12 @@ def get_features_from_partstudio(self, did, wid, eid):
Gets the feature list for specified document / workspace / part studio.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- eid (str): Element ID
did (str): Document ID
wid (str): Workspace ID
eid (str): Element ID
Returns:
- requests.Response: Onshape response data
requests.Response: Onshape response data
"""

return self.request(
Expand All @@ -182,12 +182,12 @@ def get_features_from_assembly(self, did, wtype, wid, eid):
Gets the feature list for specified document / workspace / part studio.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- eid (str): Element ID
did (str): Document ID
wid (str): Workspace ID
eid (str): Element ID
Returns:
- json: Onshape response data
json: Onshape response data
"""

return self.request(
Expand All @@ -199,12 +199,12 @@ def get_variables(self, did, wid, eid):
Get list of variables in a variable studio.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- eid (str): Element ID
did (str): Document ID
wid (str): Workspace ID
eid (str): Element ID
Returns:
- requests.Response: Onshape response data
requests.Response: Onshape response data
"""
_request_path = "/api/variables/d/" + did + "/w/" + wid + "/e/" + eid + "/variables"

Expand All @@ -220,13 +220,13 @@ def set_variables(self, did, wid, eid, variables):
Set variables in a variable studio.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- eid (str): Element ID
- variables (dict): Dictionary of variable name and value pairs
did (str): Document ID
wid (str): Workspace ID
eid (str): Element ID
variables (dict): Dictionary of variable name and value pairs
Returns:
- requests.Response: Onshape response data
requests.Response: Onshape response data
"""

payload = [variable.model_dump() for variable in variables.values()]
Expand All @@ -245,12 +245,12 @@ def create_assembly(self, did, wid, name="My Assembly"):
Creates a new assembly element in the specified document / workspace.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- name (str, default='My Assembly')
did (str): Document ID
wid (str): Workspace ID
name (str, default='My Assembly')
Returns:
- requests.Response: Onshape response data
requests.Response: Onshape response data
"""

payload = {"name": name}
Expand Down Expand Up @@ -285,14 +285,14 @@ def download_stl(self, did, wid, eid, partID, buffer: BinaryIO):
Exports STL export from a part studio and saves it to a file.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- eid (str): Element ID
- partID (str): Part ID
- save_path (str): Path to save the STL file
did (str): Document ID
wid (str): Workspace ID
eid (str): Element ID
partID (str): Part ID
save_path (str): Path to save the STL file
Returns:
- str: Path to the saved STL file or an error message
str: Path to the saved STL file or an error message
"""

req_headers = {"Accept": "application/vnd.onshape.v1+octet-stream"}
Expand All @@ -319,13 +319,13 @@ def get_mass_property(self, did, wid, eid, partID):
Get mass properties for a part in a part studio.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- eid (str): Element ID
- partID (str): Part ID
did (str): Document ID
wid (str): Workspace ID
eid (str): Element ID
partID (str): Part ID
Returns:
- requests.Response: Onshape response data
requests.Response: Onshape response data
"""
_request_path = "/api/parts/d/" + did + "/w/" + wid + "/e/" + eid + "/partid/" + partID + "/massproperties"
_resonse_json = self.request(HTTP.GET, _request_path, {"useMassPropertiesOverrides": True}).json()
Expand All @@ -337,15 +337,15 @@ def request(self, method, path, query=None, headers=None, body=None, base_url=No
Issues a request to Onshape
Args:
- method (str): HTTP method
- path (str): Path e.g. /api/documents/:id
- query (dict, default={}): Query params in key-value pairs
- headers (dict, default={}): Key-value pairs of headers
- body (dict, default={}): Body for POST request
- base_url (str, default=None): Host, including scheme and port (if different from keys file)
method (str): HTTP method
path (str): Path e.g. /api/documents/:id
query (dict, default={}): Query params in key-value pairs
headers (dict, default={}): Key-value pairs of headers
body (dict, default={}): Body for POST request
base_url (str, default=None): Host, including scheme and port (if different from keys file)
Returns:
- requests.Response: Object containing the response from Onshape
requests.Response: Object containing the response from Onshape
"""
if query is None:
query = {}
Expand Down Expand Up @@ -414,12 +414,12 @@ def _make_auth(self, method, date, nonce, path, query=None, ctype="application/j
Create the request signature to authenticate
Args:
- method (str): HTTP method
- date (str): HTTP date header string
- nonce (str): Cryptographic nonce
- path (str): URL pathname
- query (dict, default={}): URL query string in key-value pairs
- ctype (str, default='application/json'): HTTP Content-Type
method (str): HTTP method
date (str): HTTP date header string
nonce (str): Cryptographic nonce
path (str): URL pathname
query (dict, default={}): URL query string in key-value pairs
ctype (str, default='application/json'): HTTP Content-Type
"""

if query is None:
Expand All @@ -446,13 +446,13 @@ def _make_headers(self, method, path, query=None, headers=None):
Creates a headers object to sign the request
Args:
- method (str): HTTP method
- path (str): Request path, e.g. /api/documents. No query string
- query (dict, default={}): Query string in key-value format
- headers (dict, default={}): Other headers to pass in
method (str): HTTP method
path (str): Request path, e.g. /api/documents. No query string
query (dict, default={}): Query string in key-value format
headers (dict, default={}): Other headers to pass in
Returns:
- dict: Dictionary containing all headers
dict: Dictionary containing all headers
"""

if headers is None:
Expand Down
Loading

0 comments on commit 7e626a2

Please sign in to comment.