Method and system for automatically generating software design description by using function source code

By analyzing and converting the function source code, a detailed software design description is generated, which solves the problem of inconsistency between design and coding, realizes efficient design document generation, and meets detailed design requirements.

CN120670022APending Publication Date: 2025-09-19NANJING PANDA HANDA TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510798352.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-16
Publication Date
2025-09-19

AI Technical Summary

Technical Problem

In the prior art, software design specifications are inconsistent with function coding, and detailed descriptions at the function level are difficult to implement, resulting in low quality and efficiency of software design specifications.

Method used

By performing lexical and syntactic analysis on the function source code, generating static statistical information, determining the list of functions to be tested, generating a call relationship file, combining the function information data, automatically converting and generating function description tables and flow charts, and integrating them into Word documents to form a complete software design description.

Benefits of technology

The automatic conversion of function source code to software design specifications is realized, ensuring the consistency between design documents and source code, improving the quality and generation efficiency of design specifications, and meeting the detailed design requirements of GJB438.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120670022A_ABST
    Figure CN120670022A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a system for automatically generating a software design description by using a function source code. The method specifically comprises the following steps of: firstly, selecting a function to be described by an analysis program according to a function list and a calling relationship; the conversion program generates a description document with the function to be tested as a parent chapter and the called function as a child chapter; secondly, generating a function description table and a Viso or bmp format flow chart through automatic conversion for description of each function, and storing the function description table and the Viso or bmp format flow chart in the form of the function description table and the flow chart; and finally, converting a plurality of functions which are selected to be explained into a Word document in the form of a function explanation table and a flow chart, and fusing the Word document into a software design explanation document to form a complete explanation of the software. According to the method, the function source code can be automatically converted into the software design description, so that the consistency of the design document and the source code is fundamentally ensured, and the software design description document preparation efficiency and the software design description document quality are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software design in electronic information technology, and in particular to a method and system for automatically generating software design instructions using function source code. Background Art

[0002] GJB438 requires that software design specifications must be detailed at the function level, that is, they must be able to guide coders in writing functions. In the forward development process, if software design specifications are carried out from function design specifications to function coding, it will be difficult to implement because a large number of functions in historical versions have not been described in detail or in progress. For software that has been designed and developed in a forward manner, there may be inconsistencies between the coding implementation and the design specifications. Therefore, there needs to be a method that can automatically convert the function source code into a design specification document to ensure that the design specification is completely consistent with the coding. Summary of the Invention

[0003] The purpose of the present invention is to provide a method and system for automatically generating software design specifications, which can ensure the consistency of design documents and source code, and improve the document quality and document production efficiency of software design specifications.

[0004] The technical solution for achieving the purpose of the present invention is: a method for automatically generating software design specifications using function source code, the steps of which are as follows:

[0005] Step 1: The analysis program performs lexical analysis and grammatical analysis on the function source code to generate function static statistics;

[0006] Step 2: Determine a list of functions to be tested from the statistical information, and save the function information and global variable information in the form of a data file using serialization technology based on the list of functions to be tested;

[0007] Step 3: The conversion program uses serialization technology to read the function information data and generate a call relationship file. By viewing the call relationship file, the function call status of the function is obtained and the list of functions to be explained is determined;

[0008] Step 4: The conversion program generates a description document based on the information listed in the list of functions to be described and the function information data, with the function to be tested as the parent section and the called functions as the child sections;

[0009] Step 5: For each function description, the function description table and Viso or bmp format flow chart are automatically converted and saved in the form of function description table + flow chart;

[0010] Step 6: Convert multiple selected functions into a Word document in the form of a function description table + flow chart, and integrate the Word document into the software design description document to form a complete description of the software.

[0011] A system for automatically generating software design specifications using function source code, the system is used to implement the method for automatically generating software design specifications using function source code, the system includes first to sixth modules, and the functions of each module are as follows:

[0012] In the first module, the analysis program performs lexical analysis and syntax analysis on the function source code and generates function static statistics;

[0013] The second module determines a list of functions to be tested from the statistical information, and uses serialization technology to save the information of the functions to be tested and the global variable information in the form of a data file according to the list of functions to be tested;

[0014] In the third module, the conversion program uses serialization technology to read function information data and generate a call relationship file. By viewing the call relationship file, the function call status of the function is obtained and the list of functions to be explained is determined;

[0015] In the fourth module, the conversion program generates a description document with the function to be tested as the parent chapter and the called function as the child chapter based on the information listed in the list of functions to be described and combined with the function information data;

[0016] The fifth module automatically converts the description of each function into a function description table and a Viso or bmp format flow chart, and saves it in the form of function description table + flow chart;

[0017] The sixth module converts multiple selected functions into a Word document in the form of a function description table + flow chart, and integrates the Word document into the software design description document to form a complete description of the software.

[0018] A mobile terminal includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the method for automatically generating software design specifications using function source code is implemented.

[0019] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method for automatically generating software design specifications using function source code.

[0020] Compared with the prior art, the present invention has the following significant advantages: (1) the present invention is used for the automatic conversion of function source code into software design description, so that the software design description fully meets the detailed design description requirements of the function / module level specified in GJB438, and fundamentally guarantees the consistency between the design document and the source code; (2) the speed of drafting the software design description document in the process of software forward development is improved, and the quality of the software design description document and the efficiency of generating the software design description document are improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 The present invention is a flowchart of a method for automatically generating software design specifications using function source code.

[0022] Figure 2 Schematic diagram of the source code of the function in the embodiment of the present invention.

[0023] Figure 3 This is a flowchart of the function fun automatically converted and generated in an embodiment of the present invention.

[0024] Figure 4 This is a flowchart of the function fun1 automatically converted and generated in an embodiment of the present invention.

[0025] Figure 5 This is a flowchart of the function fun2 automatically converted and generated in an embodiment of the present invention. DETAILED DESCRIPTION

[0026] The present invention provides a method for automatically generating a software design specification using function source code, comprising the following steps:

[0027] Step 1: The analysis program performs lexical analysis and grammatical analysis on the function source code to generate function static statistics;

[0028] Step 2: Determine a list of functions to be tested from the statistical information, and save the function information and global variable information in the form of a data file using serialization technology based on the list of functions to be tested;

[0029] Step 3: The conversion program uses serialization technology to read the function information data and generate a call relationship file. By viewing the call relationship file, the function call status of the function is obtained and the list of functions to be explained is determined;

[0030] Step 4: The conversion program generates a description document based on the information listed in the list of functions to be described and the function information data, with the function to be tested as the parent section and the called functions as the child sections;

[0031] Step 5: For each function description, the function description table and Viso or bmp format flow chart are automatically converted and saved in the form of function description table + flow chart;

[0032] Step 6: Convert multiple selected functions into a Word document in the form of a function description table + flow chart, and integrate the Word document into the software design description document to form a complete description of the software.

[0033] Furthermore, the static statistical information of the function in step 1 includes function name, fan-out number, fan-in number, cyclomatic complexity, number of input parameters, sub-function depth, number of local variables, file name, number of .c source files, number of .cpp source files, number of .h header files, total number of source file lines, valid code lines, total number of modules, number of modules with statement count > 200 lines, average software comment rate, number of files with comment rate < 20%, number of modules with fan-out number ≥ 7, number of modules with function parameters > 10, number of modules with cyclomatic complexity > 10, proportion of cyclomatic complexity ≤ 10, proportion of cyclomatic complexity > 10, proportion of cyclomatic complexity > 15, and number of goto statements.

[0034] Furthermore, the list of functions to be explained in step 3 is directly selected by the functions to be tested for software whose scale is smaller than the set value.

[0035] Furthermore, the description of each function in step 5 is automatically converted to generate a function description table and a Viso or bmp format flow chart, as follows:

[0036] Use component object model technology to interact with Viso and Word office software to automatically draw flow charts and generate Word documents.

[0037] The present invention provides a system for automatically generating software design specifications using function source code. The system is used to implement the method for automatically generating software design specifications using function source code. The system includes first to sixth modules, and the functions of each module are as follows:

[0038] In the first module, the analysis program performs lexical analysis and syntax analysis on the function source code and generates function static statistics;

[0039] The second module determines a list of functions to be tested from the statistical information, and uses serialization technology to save the information of the functions to be tested and the global variable information in the form of a data file according to the list of functions to be tested;

[0040] In the third module, the conversion program uses serialization technology to read function information data and generate a call relationship file. By viewing the call relationship file, the function call status of the function is obtained and the list of functions to be explained is determined;

[0041] In the fourth module, the conversion program generates a description document with the function to be tested as the parent chapter and the called function as the child chapter based on the information listed in the list of functions to be described and combined with the function information data;

[0042] The fifth module automatically converts the description of each function into a function description table and a Viso or bmp format flow chart, and saves it in the form of function description table + flow chart;

[0043] The sixth module converts multiple selected functions into a Word document in the form of a function description table + flow chart, and integrates the Word document into the software design description document to form a complete description of the software.

[0044] The present invention provides a mobile terminal comprising a memory, a processor and a computer program stored in the memory and operable on the processor. When the processor executes the program, the method for automatically generating software design specifications using function source code is implemented.

[0045] The present invention provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps in the method of automatically generating software design specifications using function source code are implemented.

[0046] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0047] Example

[0048] like Figure 1 As shown, the method of automatically generating software design specifications using function source code of the present invention includes the following steps:

[0049] Step 1: The analysis program performs lexical analysis and grammatical analysis on the function source code to generate function static statistics;

[0050] The function static statistical information includes function name, fan-out number, fan-in number, cyclomatic complexity, number of input parameters, sub-function depth, number of local variables, file name, number of .c source files, number of .cpp source files, number of .h header files, total number of source file lines, valid code lines, total number of modules, number of modules with statement count > 200 lines, average software comment rate, number of files with comment rate < 20%, number of modules with fan-out count ≥ 7, number of modules with function parameters > 10, number of modules with cyclomatic complexity > 10, proportion of cyclomatic complexity ≤ 10, proportion of cyclomatic complexity > 10, proportion of cyclomatic complexity > 15, and number of goto statements.

[0051] Step 2: Determine a list of functions to be tested from the statistical information, and save the function information and global variable information in the form of a data file using serialization technology based on the list of functions to be tested;

[0052] Step 3: The conversion program uses serialization technology to read the function information data and generate a call relationship file. By viewing the call relationship file, the function call status of the function is obtained and the list of functions to be explained is determined;

[0053] For smaller software, you can directly select the function to be tested.

[0054] Step 4: The conversion program generates a description document based on the information listed in the list of functions to be described and the function information data, with the function to be tested as the parent section and the called functions as the child sections;

[0055] Step 5: For the description of each function, the component object model technology is used to interact with Viso and Word office software, automatically draw a flowchart and automatically generate a Word document, and save it in the form of "function description table" + "flowchart";

[0056] Step 6: Convert multiple selected functions into a Word document in the form of "Function Description Table" + "Flowchart", and integrate the Word document into the "Software Design Description" document to form a complete description of the software.

[0057] like Figure 1 As shown, this embodiment provides a method for automatically generating software design specifications using function source code, the function source code is as follows Figure 2 The specific steps are as follows:

[0058] Step 1. The analysis program performs lexical analysis and syntax analysis on the function source code to generate function static statistical information, including function name, fan-out number, fan-in number, cyclomatic complexity, number of input parameters, sub-function depth, number of local variables, file name, number of .c source files, number of .cpp source files, number of .h header files, total number of source file lines, valid code lines, total number of modules, number of modules with statement number > 200 lines, average software comment rate, number of files with comment rate < 20%, number of modules with fan-out number ≥ 7, number of modules with function parameters > 10, number of modules with cyclomatic complexity > 10, proportion of cyclomatic complexity ≤ 10, proportion of cyclomatic complexity > 10, proportion of cyclomatic complexity > 15, and number of goto statements.

[0059] Step 2: Determine a list of functions to be tested from the statistical information, and save the function information and global variable information in the form of a data file using serialization technology based on the list of functions to be tested;

[0060] Step 3: The conversion program uses serialization technology to read the function information data and generate a call relationship file. By viewing the call relationship file, the function call information of the function is obtained and the list of functions to be explained is determined, as shown in Table 1:

[0061] Table 1 Conversion example - functions to be tested and explained

[0062]

[0063] Step 4: The conversion program generates a description document based on the information listed in the list of functions to be described and the function information data, with the function to be tested as the parent section and the called functions as the child sections;

[0064] Step 5: For the description of each function, the component object model technology is used to interact with Viso and Word office software, automatically draw a flowchart and automatically generate a Word document, and save it in the form of "function description table" + "flowchart";

[0065] Step 6: Convert multiple selected functions into a Word document in the form of "Function Description Table" + "Flowchart", and integrate the Word document into the "Software Design Description" document to form a complete description of the software.

[0066] The Software Design Description document is shown in Table 2:

[0067] Table 2 Conversion example - converted Word document

[0068]

[0069] Table 2-1

[0070]

[0071] Table 2-2

[0072]

[0073] Table 2-3

[0074]

[0075] It can be seen that the method of the present invention for automatically generating software design descriptions using function source code is used for the automatic conversion of function source code to software design descriptions, so that the software design descriptions fully meet the detailed design description requirements of the function / module level specified in GJB438, fundamentally ensuring the consistency between the design documents and the source code, and greatly improving the document quality and document production efficiency of the software design descriptions.

[0076] The above are only preferred embodiments of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for automatically generating software design specifications using function source code, characterized in that: Here are the steps: Step 1: The analysis program performs lexical analysis and grammatical analysis on the function source code to generate function static statistics; Step 2: Determine a list of functions to be tested from the statistical information, and save the function information and global variable information in the form of a data file using serialization technology based on the list of functions to be tested; Step 3: The conversion program uses serialization technology to read the function information data and generate a call relationship file. By viewing the call relationship file, the function call status of the function is obtained and the list of functions to be explained is determined; Step 4: The conversion program generates a description document based on the information listed in the list of functions to be described and the function information data, with the function to be tested as the parent section and the called functions as the child sections; Step 5: For each function description, the function description table and Viso or bmp format flow chart are automatically converted and saved in the form of function description table + flow chart; Step 6: Convert multiple selected functions into a Word document in the form of a function description table + flow chart, and integrate the Word document into the software design description document to form a complete description of the software.

2. The method for automatically generating software design specifications using function source code according to claim 1, characterized in that: The static statistical information of the functions in step 1 includes the function name, fan-out number, fan-in number, cyclomatic complexity, number of input parameters, sub-function depth, number of local variables, file name, number of .c source files, number of .cpp source files, number of .h header files, total number of source file lines, valid code lines, total number of modules, number of modules with more than 200 lines of statements, average software comment rate, number of files with comment rate <20%, number of modules with fan-out number ≥7, number of modules with function parameters >10, number of modules with cyclomatic complexity >10, proportion of modules with cyclomatic complexity ≤10, proportion of modules with cyclomatic complexity >10, proportion of modules with cyclomatic complexity >15, and number of goto statements.

3. The method for automatically generating software design specifications using function source code according to claim 1, characterized in that: The list of functions to be explained in step 3 is directly selected by the functions to be tested for software whose scale is smaller than the set value.

4. The method for automatically generating software design specifications using function source code according to claim 1, characterized in that: The description of each function in step 5 is automatically converted to generate a function description table and a Viso or bmp format flow chart, as follows: Use component object model technology to interact with Viso and Word office software to automatically draw flow charts and generate Word documents.

5. A system for automatically generating software design specifications using function source code, characterized in that: The system is used to implement the method for automatically generating software design specifications using function source code as described in any one of claims 1 to 4. The system includes a first module to a sixth module, and the functions of each module are as follows: In the first module, the analysis program performs lexical analysis and syntax analysis on the function source code and generates function static statistics; The second module determines a list of functions to be tested from the statistical information, and uses serialization technology to save the information of the functions to be tested and the global variable information in the form of a data file according to the list of functions to be tested; In the third module, the conversion program uses serialization technology to read function information data and generate a call relationship file. By viewing the call relationship file, the function call status of the function is obtained and the list of functions to be explained is determined; In the fourth module, the conversion program generates a description document with the function to be tested as the parent chapter and the called function as the child chapter based on the information listed in the list of functions to be described and combined with the function information data; The fifth module automatically converts the description of each function into a function description table and a Viso or bmp format flow chart, and saves it in the form of function description table + flow chart; The sixth module converts multiple selected functions into a Word document in the form of a function description table + flow chart, and integrates the Word document into the software design description document to form a complete description of the software.

6. A mobile terminal comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method for automatically generating software design specifications using function source code as described in any one of claims 1 to 4 is implemented.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method for automatically generating software design specifications using function source code as described in any one of claims 1 to 4 are implemented.