Comments (7)
This is by no means finished, but a WIP here: http://neo-python.readthedocs.io/en/latest/index.html
Currently working out of the feature-docs
branch
from neo-python.
- Add in docstrings to all methods/modules etc
- Fill in docstrings with more than boilerplate
- Create sphinx documentation
- Publish to readthedocs.io
from neo-python.
Any good document that shows how the docstrings should look for sphinx compatibility? I find there website a bit messy. Perhaps some samples how to document function parameters, return type would be nice.
from neo-python.
I personally like the Google style docstrings:
- http://www.sphinx-doc.org/en/stable/ext/example_google.html
- http://google.github.io/styleguide/pyguide.html?showone=Comments#Comments
This is how it's done in neo-boa:
- Docstrings: https://github.com/CityOfZion/neo-boa/blob/master/boa/compiler.py
- Generated docs: http://neo-boa.readthedocs.io/en/latest/_modules/boa/compiler.html#Compiler
Here is another example with:
- Docstrings: https://github.com/metachris/logzero/blob/master/logzero/__init__.py#L379
- Generated docs: https://logzero.readthedocs.io/en/latest/#i-logzero-logfile
from neo-python.
I started converting #74 to rST format as requested by @localhuman here. Unfortunately also that standard leaves room for interpretation / free will. Before having to edit everything a 3rd time I'd like to get to an agreement on how to document the following:
- multiple return types
- exceptions
- notes
multiple return types
Example with current Sphinx Napoleon format:
"""
Change the password used to protect the private key.
Args:
password_old (str): the current password used to encrypt the private key.
password_new (str): the new to be used password to encrypt the private key.
Returns:
bool: False, if the old password does not match the current saved password.
None: If successfully changed the password.
"""
Attempt 1:
:return: False, if the old password does not match the current saved password. None, If succesfully changed the password.
:rtype: bool, None
Attempt 2 (suggested here):
Note: this drops the :rtype:
:return:
bool False if the old password does not match the current saved password.
None None If successfully changed the password.
Exception documentation
Example:
"""
Retrieve the script_hash from an address.
Args:
address (str): a base58 encoded address.
Raises:
ValuesError: if an invalid address is supplied or the coin version is incorrect.
Exception: if the address checksum fails.
Returns:
UInt160: script hash
"""
PyCharm format:
:raises: :exc:
ExceptionType
:raises: :exc: `ValueError` if an invalid address is supplied or the coin version is incorrect.
:raises: :exc: `Exception` if the address checksum fails.
Note that I'm uncertain here if I should repeat :raises:
and if it's ok to add the description behind it.
Sphynx doc example
:raises ValueError: if an invalid address is supplied or the coin version is incorrect.
:raises Exception: if the address checksum fails.
Notes
Current:
"""
Add a watch only address to the wallet.
Args:
script_hash (UInt160): a bytearray (len 20) representing the public key.
Returns:
None
Note:
Prints a warning to the console if the address already exists in the wallet.
"""
Attempt (ok?)
"""
Add a watch only address to the wallet.
:param script_hash: a bytearray (len 20) representing the public key.
:type script_hash: UInt160
.. note:: Prints a warning to the console if the address already exists in the wallet.
:return:
"""
from neo-python.
It's probably good to say we settled on using Google's docstring notation and no longer the rST format discussed just above.
from neo-python.
This is complete, though further documentation would never hurt.
from neo-python.
Related Issues (20)
- Circular map reference causes Python stack overflow
- Docker build exits with errors HOT 9
- Parser breaks when reading --tx-attr argument with spaces HOT 3
- Privatenet fails to initialize HOT 2
- neo-python can't sync with Neo 2.10.3 nodes HOT 1
- Deploy Neo Smart Contract at runtiime. HOT 5
- Wallet & np-api-server issues HOT 2
- BigInteger ToByteArray incompatible with neo-vm v3.0.0 HOT 1
- Unclaimed gas calculation incorrect HOT 6
- About NEP-5 Smart Contracts HOT 8
- docker 只有Ubuntu的吗,在centos上运行出错
- centos7下,运行np-prompt,卡顿后后,ctrl + z 退出后,再此运行np-prompt,报错 HOT 1
- 运行np-prompt后,prompt.log中报错, HOT 1
- 运行np-prompt后,没有出现NEO命令行
- Connect to node problem HOT 2
- TestNet bootstrap HOT 1
- prompt input parser parses nested lists incorrectly HOT 1
- Simple Policy Plugin HOT 6
- np-bootstrap -c configure my local sync node that haved sync and the block data is finish. HOT 1
- np-bootstrap hangs at confirm prompt HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neo-python.