Abstract:Code comment generation has been an important research task in the field of software engineering in the past few years. Some existing work has achieved impressive results on the open source datasets that containing a large number of <code snippet, comment> pairs. However, in the practice of software enterprises, the code to be commented is usually belong to a software project. Different from the code snippets in the open source datasets, the code in a software project has different length and granularity, developers need to know not only how to add comment, but also where to add comments, namely commenting decision. In this paper, we propose CoComment, a software project-oriented code comment generation approach. This approach automatically extracts domain-specific concepts from software documents, then propagates and expands these concepts by code parsing and text matching. On this basis, an automatic code commenting decision method is made by locating code lines or segments related to these concepts, and corresponding natural language comments are generated by fusing concepts and context. We conduct comparative experiments on 3 software projects, containing more than 46,000 manually annotated code comments. The experimental results demonstrate our approach makes code commenting decision accurately and generates more helpful comments compared with existing work, which effectively solve the problem of automatic code comment for software project.