QueryJane | Python code Autodoc configuration - Documented Account module.
Repository
https://github.com/roadhousestudio/queryjane_app
QueryJane is a web application developed with Django that allows to connect with companies and experts in different sectors of the cannabis industry. Beta version is available here.
![Screen Shot 2018-06-04 at 10.46.34 PM.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmQGs71ZPHUVMe2hLQtoXG52WcjptAq3kRW6HcpjRYG2kZ/Screen%20Shot%202018-06-04%20at%2010.46.34%20PM.png)
Details
I have been working to activate the Sphinx autodoc module. This allows to include in our project documentation the docstrings include in our python code. In this way, we can add documentation to our Python modules and pull it in our final official documentation in a semi-automatic way.
Take a look to the correct way to add docstring to our Python code:
![Screen Shot 2018-06-22 at 10.27.24 PM.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmQfR4Ye48Eqq58VhDRrW7VHg3civGTvN6moVF2MJxAEug/Screen%20Shot%202018-06-22%20at%2010.27.24%20PM.png)
In this way, Sphinx will recognize the added docstrings and will include them in the generated documentation.
I will show you how to indicate to Sphinx that a documented file must be included. Per example, if we want to include to docstrings from the account.models.py file, we must add the following code into the .rst files:
![Screen Shot 2018-06-22 at 10.35.14 PM.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmNf7udbkgrhXgqsnnqFh6yqzmdcGTtTrru5LZxbDvvwe8/Screen%20Shot%202018-06-22%20at%2010.35.14%20PM.png)
In this way, we are telling to Sphinx that must include all the members of the account/models.py module into the final documentation. Also, we are including all the inherited members and we are including the inheritance path. To goal of include the inheritance documentation, is that in most cases the classes and functions that we are generation have some type of inheritance, and many times we want to override these inherited members. Include this in the documentation allow us to find the members structure in a easy way, without having to go look in the Django repository.
In this documentation update, I have documented the account app Python files. This is the detailed structure of the new documentation module, in which I'm adding all Python files of this module.
To include docstrings from Python files, we must add some lines to the conf.py file. really, and because I'm new using Sphinx, find the correct lines to include the docstring from the Python files in the correct way took me a long time. These are the necessary Sphinx configuration to include docstrings from Python files in a Django project.
import os
import sys
sys.path.insert(0, os.path.abspath('../../')) # Path the the project root from the current file location
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
# Setup Django
import django
django.setup()
It takes a lot of time to me and, after a lot of failed attempts, I have created this question in Stackoverflow. Somebody give me the solution and for this reason I was able to create the new documentation module.
Components
The new documented parts are all the classes and functions defined in the Python files in the account app.
Difference
The impact is that now the defined classes and functions can be easily found, including their inherited members. Per now, I'm including only the Python files of one specific module, but the necessary settings to run Sphinx autodoc in the project in a correct way has been configured and it will allows to document the other modules very fast.
Links
New documentation module is available in the following url:
http://docs.queryjane.net/code_documentation.html
Documentation homepage:
GitHub Proof of Authorship
This update includes PRs From 103 to 114, but many of these PRs are about some fixes, typo bugs and changes to testing the correct configuration. The following list shows the most relevant PRs.
cool code, will have to check it out, cannabis and code a good combination
Please Upvote➜https://steemit.com/christianity/@bible.com/verse-of-the-day-revelation-21-8-niv
Congratulations! Your post has been selected as a daily Steemit truffle! It is listed on rank 11 of all contributions awarded today. You can find the TOP DAILY TRUFFLE PICKS HERE.
I upvoted your contribution because to my mind your post is at least 18 SBD worth and should receive 37 votes. It's now up to the lovely Steemit community to make this come true.
I am
TrufflePig
, an Artificial Intelligence Bot that helps minnows and content curators using Machine Learning. If you are curious how I select content, you can find an explanation here!Have a nice day and sincerely yours,
![trufflepig](https://steemitimages.com/640x0/https://raw.githubusercontent.com/SmokinCaterpillar/TrufflePig/master/img/trufflepig17_small.png)
TrufflePig
Good Work with the documentation of the project.
I really think the documentation part can be impoved a lot more.
Good Luck for it.
Thanks!
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
Hey @kit.andres
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!