Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何记录Django项目?_Python_Django - Fatal编程技术网

Python 如何记录Django项目?

Python 如何记录Django项目?,python,django,Python,Django,我应该如何开始记录Django项目?我不是在说我正在创建的应用程序,我将推送到github。它基本上是内部文档,将帮助我们雇用的新开发人员跟上系统的速度。(我想这就是一般文档的要点) 我是否应该按照以下方式记录每个视图功能、模型或表单: def home(request): """View that renders the home page.""" class MyModel(models.Model): "Documentation regarding my model."

我应该如何开始记录Django项目?我不是在说我正在创建的应用程序,我将推送到github。它基本上是内部文档,将帮助我们雇用的新开发人员跟上系统的速度。(我想这就是一般文档的要点)

我是否应该按照以下方式记录每个视图功能、模型或表单:

def home(request):
    """View that renders the home page."""

class MyModel(models.Model):
    "Documentation regarding my model."""

这似乎有点过分了。也许有一些好的项目可以让我从中获得灵感吗?

根据我的经验,编写代码并让新开发人员理解代码的一种有效方法是识字编程

最重要的是,有一个真正解释发生了什么的叙述,而不是一套松散的评论

我更喜欢非标准形式的有文化的编程, 我把我的评论放在代码后面,而不是中间。 有经验的开发人员不会因此受到阻碍

就像:

class Node (object):                                    # Node representing atomary partial state in a state machine
    def __init__ (self, value = Nothing):               # Initial value is optional, not needed in case of dependent nodes ('Nothing' introduced y15m02d14)
        self.sinkNodes = []                             # Nodes that depend on this node
        self.links = []                                 # Zero or more links to bareRead / bareWrite pairs
        self.exceptions = []
        self.actions = []
        self.validator = lambda value: True             # Validators are deprecated, use exceptions instead

        self.persistent = False                         # Assume not worth persisting
        self.recursionCount = 0

        if value ==  Nothing:                           # If node is uninitialized
            self.event = 0                              #   It should be updated
        else:                                           # If node is supposed to be freely initialized
            self.currentValue = value                   #   Free initialisation
            self.previousValue = self.currentValue      #   Make sure previousValue is available in case of free initialisation
            self.event = currentEvent ()                #   Remember up to date

            if not value is None:                       #   If it is a freely initialized ordinary node rather than an event-only node
                self.persistent = True                  #       Remember it is part of a non-redundant basis for persistence


(etc.)
另一方面,盲目地在每个类和函数上加上明显的注释,然后用工具生成文档,对我理解任何东西都没有多大帮助。我需要手头有实际的代码,这里就是这样

在代码中真正困难的地方,在整个宽度上有一个解释块是没有坏处的

'''
As soon as we encounter a module in the chain that isn't already there, we'll have to create the remainder (tail) of the chain.

    e.g.
        import a.b.c.d.e
        import a.b.c

    will generate
        modules = {}
        __nest__ (a, 'b.c.d.e', __init__ (__world__.a.b.c.d.e))
        __nest__ (a, 'b.c', __init__ (__world__.a.b.c))

    The task of the __nest__ function is to start at the head object and then walk to the chain of objects behind it (tail),
    creating the ones that do not exist already, and insert the necessary module reference attributes into them.
'''

def __nest__ (headObject, tailNames, value):
    current = headObject

(etc.)

你是说Django项目?Django的admindocs应用程序从安装的应用程序中的模型、视图、模板标签和模板过滤器的文档字符串中提取文档,并从Django管理员处获取这些文档。谢谢,我不知道。按照给定的详细程度记录每个视图和模型似乎有点过头了。我想知道是否有大型项目真的做到了这一点?这种语法会生成超链接,这样您就可以浏览文档了。