8000 Merge pull request #221 from dev-mkc19/20220309_doc_update · ManuelVoiden/document-api-python@cf80554 · GitHub
[go: up one dir, main page]

Skip to content

Commit cf80554

Browse files
authored
Merge pull request tableau#221 from dev-mkc19/20220309_doc_update
Update datasource model docs
2 parents 6177826 + 85c1b5c commit cf80554

File tree

3 files changed

+80
-2
lines changed

3 files changed

+80
-2
lines changed

docs/docs/api-ref.md

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,39 @@ 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+
save
56+
57+
save_as
58+
59+
add_calculation
60+
61+
**Properities:**
62+
63+
`self.name` Returns string with the name of datasource.
64+
65+
`self.version` Returns string of daatasource's version.
66+
67+
`self.caption` Returns string of user defined name of datasource if exists.
68+
69+
`self.connections` Returns list of connections are used in workbook.
70+
71+
`self.fileds` Returns key-value result of field name and their attributes.
72+
73+
`self.calculations` Returns calculated field of the workbook.
4574

4675
## Connections
4776
```python
@@ -74,5 +103,48 @@ The Connection class represents a tableau data connection. It can be from any ty
74103

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

tableaudocumentapi/datasource.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,17 @@ def save_as(self, new_filename):
184184

185185
@property
186186
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