-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(DB): Add a few docs for database. #230
Conversation
ef28adf
to
196d738
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this. Some questions and minor concerns:
nixnet/database/_collection.py
Outdated
"""Return the database object. | ||
|
||
Args: | ||
Name of database object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're following our documentation style guide:
key(str): Name of database object.
nixnet/database/database.py
Outdated
@@ -56,33 +57,89 @@ def __hash__(self): | |||
def __repr__(self): | |||
return '{}(handle={})'.format(type(self).__name__, self._handle) | |||
|
|||
def close(self, close_all_refs=False): | |||
def close(self, close_all=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we changing the default to True? Can you elaborate. This is a breaking API change so we should call it out in the commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking at the LV API docs. I'll revert this and follow the C API docs.
nixnet/database/database.py
Outdated
To simplify the task of closing all database objects you opened, you | ||
can use the ``close_all`` parameter set to true (default); otherwise, | ||
only the database object is closed. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This documentation doesn't seem to match the C API docs here. Can you share the source of this content? It seems to be missing some of the info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed the LabVIEW docs group properties by object (e.g. - the python Cluster class groups properties similarly to a Cluster property node) and thought it might make sense to use LV docs. I now see, we should only use the C API docs.
nixnet/database/_collection.py
Outdated
return self._factory(ref) | ||
else: | ||
raise TypeError(index) | ||
raise TypeError(key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would refrain from making such changes. Rationale is twofold:
-
We should avoid any variable name changes unless we have a strong reason to do so. Either would've been fine in this case. It adds unnecessary risk and review burden.
-
This breaks compatibility for users that use param name when passing in value - so we should be minimizing these things.
Same applies to close_all_refs
and db_filepath
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll revert, but the only question I have is whether close_all_refs
makes sense in the python API, since we don't refer to refs otherwise. Does @epage have any thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized I should add docs for Database __init__
and that the C API docs on nxdbOpenDatabase explain refs in context of opening/closing a database. close_all_refs
makes sense.
nixnet/database/database.py
Outdated
path. If opened as an alias, it uses the file path registered for that | ||
alias. | ||
|
||
Args: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you share the source of this content? We typically use the C API documentation word for word with minor changes/tweaks to make it more "pythonic".
See C API doc here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, LV docs. I'll change to C docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did modify the C API docs for this a bit to exclude info about saving (exporting) a cluster, and I opened issue #231 to add a save method to class Cluster.
nixnet/database/database.py
Outdated
For CANdb (.dbc), LDF (.ldf), or NI-CAN (.ncd) files, the file contains | ||
only one cluster, and no cluster name is stored in the file. For these | ||
database formats, NI-XNET uses the name Cluster for the single cluster. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you share the source of this content?
f79de6f
to
3a7ba2d
Compare
nixnet/database/database.py
Outdated
granted, and the database uses computer resources (memory and handles). For | ||
more information, refer to :any:`nixnet.database.database.Database.close`. | ||
|
||
Args: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may seem strange to put Args here, but I did that because our current Sphinx configuration ignores init docstrings (I created issue #232 ). It looks good on the generated docs though since the class header on readthedocs does show the constructor args.
fd5840f
to
dace8cf
Compare
docs/conf.py
Outdated
|
||
current_year = datetime.datetime.now().year | ||
if copyright_year != current_year: | ||
warnings.warn('Copyright year is %s. Current year is %s.' % (copyright_year, current_year)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a warning?
Should we just always use datetime.datetime.now().year in the copyright?
5042b52
to
f156042
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job on the first pass for documentation. I have some minor comments below.
@@ -1,4 +1,4 @@ | |||
Copyright (c) 2017, National Instruments Corp. | |||
Copyright (c) 2017-2018, National Instruments Corp. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this!
|
||
When an already open database is opened, | ||
this class grants access to the same database and increases an internal reference counter. | ||
A multiple referenced (open) database must be closed as many times as it has been opened. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"A multiple referenced (open) database must be closed as many times as it has been opened."
Should we capture this as a Note in the docstring? And explain that in python upon database
object exit, close
will get called automatically for them.
|
||
If ``db_filepath`` is empty, the file is saved to the same FIBEX file specified when opened. | ||
If opened as a file path, it uses that file path. | ||
If opened as an alias, it uses the file path registered for that alias. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in-person we should add any docstrings about references to RT anyway, even if we're not supporting RT right now so we don't have to come back and write those comments.
author = u'National Instruments' | ||
copyright = u'2017-{}, {}'.format(datetime.now().year, author) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Document database/database.py and database/_collection.py.
Copyright year(s) should now be 2017-2018. Update conf.py so that Sphinx generates doc copyrights that end with the current year.
6cad32b
to
fad6e51
Compare
Document database/database.py and database/_collection.py.
tox
successfully runs, including unit tests and style checks (see CONTRIBUTING.md).