Skip to content

Commit

Permalink
Updating Endpoint Documentation Generator for #19
Browse files Browse the repository at this point in the history
  • Loading branch information
swar committed Dec 12, 2018
1 parent bea35e7 commit d2c94bf
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
3 changes: 3 additions & 0 deletions docs/version_log.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
`Documentation`
* Updating Endpoint docs with Python variables for [#19](https://github.com/swar/nba_api/issues/19).

`Endpoint Documentation Generator`
* Updating Endpoint docs with Python variables for [#19](https://github.com/swar/nba_api/issues/19).

# `v1.0.6`
#### 2018-10-11
* Accidentally distributed with DEBUG Mode enabled in `v1.0.5`.
Expand Down
11 changes: 10 additions & 1 deletion tools/stats/endpoint_documentation_generator/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,20 @@ def get_endpoint_documentation(endpoint, endpoints_information):
.replace('|', r'\|'))
required = ''
nullable = ''
map_key = 'non-nullable'
if parameter in required_parameters:
required = '`Y`'
if parameter in nullable_parameters:
nullable = '`Y`'
parameter_line = parameter_line_template.format(parameter=parameter, pattern=pattern, required=required, nullable=nullable)
map_key = 'nullable'

python_parameter_class = parameter_map[parameter][map_key][parameter_patterns[parameter]]
python_parameter_variable = get_python_variable_name(python_parameter_class)

parameter_line = parameter_line_template.format(api_parameter_name=parameter,
python_parameter_class=python_parameter_class,
python_parameter_variable=python_parameter_variable,
pattern=pattern, required=required, nullable=nullable)
if parameter in nullable_parameters:
parameter_texts.append(parameter_line)
else:
Expand Down
7 changes: 4 additions & 3 deletions tools/stats/endpoint_documentation_generator/template.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
endpoint_documentation_template = '''# {endpoint}
##### [nba_api/stats/endpoints/{endpoint__lowercase}.py](https://github.com/swar/nba_api/blob/master/nba_api/stats/endpoints/{endpoint__lowercase}.py)
##### Endpoint URL
>[https://stats.nba.com/stats/{endpoint__lowercase}](https://stats.nba.com/stats/{endpoint__lowercase})
Expand All @@ -7,8 +8,8 @@
>[https://stats.nba.com/stats/{endpoint__lowercase}?{query_string_parameters}](https://stats.nba.com/stats/{endpoint__lowercase}?{query_string_parameters})
## Parameters
Parameter Name | Pattern | Required | Nullable
------------ | :-----------: | :---: | :---:
API Parameter Name | Python Parameter Class | Python Parameter Variable | Pattern | Required | Nullable
------------ | ------------ | ------------ | :-----------: | :---: | :---:
{parameters}
## Data Sets
Expand All @@ -27,4 +28,4 @@
```
'''

parameter_line_template = '''_**{parameter}**_ | {pattern} | {required} | {nullable} | '''
parameter_line_template = '''_**{api_parameter_name}**_ | [{python_parameter_class}](https://github.com/swar/nba_api/blob/master/docs/nba_api/stats/library/parameters.md#{api_parameter_name}) | {python_parameter_variable} | {pattern} | {required} | {nullable} | '''
13 changes: 13 additions & 0 deletions tools/stats/library/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,11 @@
'parameter_value': '',
'parameter_error_value': 'a',
},
'TwoWayNullable': {
'default_py_value': "''",
'parameter_value': '',
'parameter_error_value': 'a',
},
}

parameter_map = {
Expand Down Expand Up @@ -4248,6 +4253,14 @@
},
'non-nullable': {

}
},
'TwoWay': {
'nullable': {
None: 'TwoWayNullable'
},
'non-nullable': {

}
},
}

0 comments on commit d2c94bf

Please sign in to comment.