8000 Merge pull request #211 from dev-mkc19/development · nchelaru/document-api-python@5a4c58f · GitHub
[go: up one dir, main page]

Skip to content

Commit 5a4c58f

Browse files
authored
Merge pull request tableau#211 from dev-mkc19/development
Update documentation according to code
2 parents 6177826 + cd7e5d4 commit 5a4c58f

File tree

4 files changed

+92
-2
lines changed

4 files changed

+92
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
* Drop python 2, add up through 3.9
1616

1717

18+
## 08 (October 2021)
19+
* See dashboards in a workbook
20+
* Add shapes property
21+
* Add custom sql
22+
* Drop python 2, add up through 3.9
23+
24+
1825
## 07 (26 May 2021)
1926
* Fix bug in xfile that overwrote the namespace name when saving a document
2027

docs/docs/api-ref.md

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,43 @@ Saves any changes to the workbook to a new file specified by the `new_file` para
3838

3939
`self.filename:` Returns the filename of the workbook.
4040

41+
`self.shapes` Returns a list of strings with the names of shapes found in the workbook.
42+
4143
## Datasources
4244
```python
4345
class Datasource(dsxml, filename=None)
4446
```
47+
A class representing Tableau Data Sources, embedded in workbook files or in TDS files.
48+
49+
**Params:**
50+
51+
**Raises:**
52+
53+
**Methods:**
54+
55+
`Datasource.save(self)` Saves any changes to the datasource to the existing file.
56+
57+
`Datasource.save_as(self)` Saves any changes to the datasource to a new file specified by the `new_file` parameter.
58+
59+
`Datasource.add_field(self, name, datatype, role, field_type, caption)` Adds a base field object with the given values.
60+
61+
`Datasource.remove_field(self, field)` Remove a given field.
62+
63+
`Datasource.add_calculation(self, caption, formula, datatype, role, type)` Adds a calculated field with the given values.
64+
65+
**Properities:**
66+
67+
`self.name` Returns string with the name of datasource.
68+
69+
`self.version` Returns string of daatasource's version.
70+
71+
`self.caption` Returns string of user defined name of datasource if exists.
72+
73+
`self.connections` Returns list of connections are used in workbook.
74+
75+
`self.fileds` Returns key-value result of field name and their attributes.
76+
77+
`self.calculations` Returns calculated field of the workbook.
4578

4679
## Connections
4780
```python
@@ -74,5 +107,49 @@ The Connection class represents a tableau data connection. It can be from any ty
74107

75108
## Fields
76109
```python
77-
class Workbook(column_xml=None, metadata_xml=None)
110+
class Field(column_xml=None, metadata_xml=None)
78111
```
112+
113+
Represents a field in a datasource
114+
115+
**Raises:**
116+
117+
**Methods:**
118+
119+
`Field.create_field_xml()` Create field from scratch.
120+
121+
`Field.add_alias(self, key, value)` Add an alias for a given display value.
122+
123+
**Properities:**
124+
125+
`self.name` Returns a string providing a nice name for the field which is derived from the alias, caption, or the id.
126+
127+
`self.id` Returns a string with name of the field as specified in the file, usually surrounded by [ ].
128+
129+
`self.xml` Returns a ElementTree object which represents an XML of the field.
130+
131+
`self.caption` Returns a string with the name of the field as displayed in Tableau unless an aliases is defined.
132+
133+
`self.alias` Returns a string with the name of the field as displayed in Tableau if the default name isn't wanted.
134+
135+
`self.datatype` Returns a string with the type of the field within Tableau (string, integer, etc).
136+
137+
`self.role` Returns a string which identify field as a Dimension or Measure.
138+
139+
`self.type` Returns a string with type of field (quantitative, ordinal, nominal).
140+
141+
`self.aliases` Returns Key-value mappings of all aliases that are registered under this field.
142+
143+
`self.is_quantitative` Returns a boolean if field is quantitative.
144+
145+
`self.is_ordinal` Returns a boolean if field is categorical that has a specific order.
146+
147+
`self.is_nominal` Returns a boolean if field is categorical that does not have a specific order.
148+
149+
`self.calculation` Returns a string with the formula if this field is a calculated field.
150+
151+
`self.default_aggregation` Returns a string with he default type of aggregation on the field (e.g Sum, Avg).
152+
153+
`self.description` Returns a string with contents of the <desc> tag on a field.
154+
155+
`self.worksheets` Returns a list of strings with the worksheet's names uses this field.

tableaudocumentapi/datasource.py

Lines changed: 5 additions & 0 deletions
< 9E88 td data-grid-cell-id="diff-efb9c3a41d3d4c1331d555edb1fd8769f11bd618efa496d10f9eedb09bc494e2-186-186-0" data-selected="false" role="gridcell" style="background-color:var(--bgColor-default);text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative diff-line-number-neutral left-side">186
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,17 @@ def save_as(self, new_filename):
184184

185185
@property
186
def name(self):
187+
""" Name of the datasource. """
187188
return self._name
188189

189190
@property
190191
def version(self):
192+
""" Version of the datasource. """
191193
return self._version
192194

193195
@property
194196
def caption(self):
197+
""" User defined name for the datasourse. """
195198
return self._caption
196199

197200
@caption.setter
@@ -206,6 +209,7 @@ def caption(self):
206209

207210
@property
208211
def connections(self):
212+
""" List of connections are used in workbook. """
209213
return self._connections
210214

211215
def clear_repository_location(self):
@@ -215,6 +219,7 @@ def clear_repository_location(self):
215219

216220
@property
217221
def fields(self):
222+
""" Key-value result of field's names and its attributes. Dict. """
218223
if not self._fields:
219224
self._refresh_fields()
220225
return self._fields

tableaudocumentapi/field.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def role(self, role):
215215

216216
@property
217217
def type(self):
218-
""" Dimension or Measure """
218+
""" Type of field (quantitative, ordinal, nominal) """
219219
return self._type
220220

221221
@type.setter
@@ -336,6 +336,7 @@ def description(self):
336336

337337
@property
338338
def worksheets(self):
339+
""" Worksheets which uses field. """
339340
return list(self._worksheets)
340341

341342
######################################

0 commit comments

Comments
 (0)
0