How to quickly generate annotation documents in python,
How to quickly generate annotation documents using python
Today, we will tell you a simple example. You only need to pay attention to small details, so that you can easily generate annotation documents and check whether the class method reference names we have written are duplicated. Looking at the documents written by other professional experts, you are excited. You don't have to worry about the fact that we can use python to generate instructions that meet the requirements. This improves the overall reading of the Code, second, the overall structure of the code can be clearer, saving a lot of trouble during the handover, when taking over your work, other colleagues will not ask you what it is or what it is, because the comments have been intuitively expressed, when integrating, you can give the customer a brief description (mainly for your BOSS) in the instruction document. Then, let's look at the simple code format below for the implementation of the subject, note that both the annotation and function name class names are associated with _ all _.
#! /Usr/bin/env python #-*-coding: UTF-8, first, we need to use the _ all _ attribute in Py as all classes, functions, and variable members in the export _ all _ attribute in the module. avoid conflicting names when referencing each other. ''' _ all _ = ['login ', 'check', 'shop ', 'updateit', 'findit', 'deleteit', 'createit'] class Login: '''test comment 1: You can write a description of the role of this class. For example, this method is used to log on to '''def _ init _ (self ): '''indicates the parameters you need to initialize. You may need to use the username, password, and password''' pass def check (self) for logon ): '''describes the features you want to implement through negotiation. There are also many features such as the verification and judgment statement and Verification Code ''' passclass Shop: '''attributes and methods contained in the commodity class update change/update find search delete create add ''' def _ init _ (self ): '''pass def upDateIt (self): ''' used to update product information '''pass def findIt (self ): '''query item information''' pass def deleteIt (self): ''' Delete expired items ''' pass def createIt (self ): '''create a new product and shelving information''' passif _ name __= = "_ main _": import pythonzhushi print help (pythonzhushi)
Here, we need to emphasize that the py name should be the same as the py name you are currently working on (The py name I created here is pythonzhushi, and the import name is also used ), because the import in the following test is self-imported, the import Name and Help (name) and your file name must be consistent. For more information, see the following figure:
Of course, you can also import data from other file references. Here, you can use the common python import method from which directory to import and what file pythonzhushi
Of course, I still use images to show the following:
Is it clear at a glance, so we can also import the annotation document we need to do. The help method is to help us see a simple help document for the classes and functions contained in this file, similar to a description in the readme document. Finally, let's take a look at the masking effect:
Is it easy to print out the instructions for our program? You can directly paste this document in the following step to complete the instructions for a readme document. After testing, note that, if you want to write # This annotation should not be written to def. The above position of the annotation should be similar to that of the decorator. On the contrary, three quotation marks ''' should not be written to the def outside. This will not show the effect. Please try it now. Thank you for watching ..