Document generation method, device, electronic device and storage medium

By obtaining Java project file information non-invasively, generating Markdown and HTML documents, solving the problems of low efficiency and poor adaptability of development document generation in the existing technology, and achieving fast and flexible document generation.

CN113590189BActive Publication Date: 2025-04-15AGRICULTURAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110742397.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-30
Publication Date
2025-04-15
Estimated Expiration
2041-06-30

AI Technical Summary

Technical Problem

The existing Java project development documents are mainly completed by manpower, which consumes a lot of manpower and time and cannot fully guarantee timely and accurate updates. The existing tools invade project code and are inefficient.

Method used

Relevant information in the project file is obtained through a non-invasive way, extract the information of the class including the attributes, methods, etc. of the class, generate a Markdown document based on the Markdown layout information, and convert it into an HTML document based on the HTML style information.

Benefits of technology

It realizes rapid generation of development documents, avoids the impact on project files, is suitable for any type of Java project, and provides flexible document content and format selection to meet users' personalized needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113590189B_ABST
    Figure CN113590189B_ABST
Patent Text Reader

Abstract

The present application provides a document generation method, device, electronic device and storage medium. The document generation method includes: obtaining project path information, Markdown layout information, and HTML style information; obtaining a project file according to the project path information; extracting class information from the project file; the class information includes attribute information, method information, and other basic information in the class; generating a Markdown document based on the extracted class information according to the Markdown layout information; and converting the Markdown document into an HTML document according to the HTML style information. Extracting project-related development content information from project files in a non-invasive manner will not have any impact on project files, and can be applied to any type of Java project.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to data processing technology, and in particular to a document generation method, device, electronic device and storage medium. Background Art

[0002] In the process of Java project development, in order to increase the readability and robustness of the program and facilitate the debugging and maintenance of the program in the later stage, it is necessary to unify the technical specifications. Generally, the specifications are unified through relevant documents, such as requirement documents, development documents, flow charts, change files, etc. Among them, the development document is equivalent to the instruction manual of the program and plays an extremely important role in the life cycle of Java projects. Therefore, how to quickly generate development documents and ensure the timeliness of development documents is an extremely important issue.

[0003] At present, the development documents of most Java projects are still mainly completed by manpower, and need to be regularly maintained. While consuming a lot of manpower and time, it cannot fully guarantee timely and accurate document updates and cannot meet project needs. In addition, the development documents of some Java projects are generated using existing code comment document generation tools such as Javadoc and XDoc. However, these tools need to invade the project by adding annotations to generate development documents, which will add additional consumption to the project and have low efficiency. Summary of the invention

[0004] The present application provides a document generation method, device, electronic device and storage medium, which obtain relevant information in a project file in a non-invasive manner to generate a development document.

[0005] In a first aspect, the present application provides a document generation method, comprising:

[0006] Get project path information, Markdown layout information, and HTML style information;

[0007] According to the project path information, obtain the project file;

[0008] Extract class information from the project file; the class information includes attribute information, method information, and other basic information in the class;

[0009] Generate a Markdown document according to the Markdown layout information and based on the extracted class information;

[0010] The Markdown document is converted into an HTML document according to the HTML style information.

[0011] Optionally, extracting class information from the project file includes:

[0012] Capture annotations through document scanning;

[0013] Dynamically load the JAR package in the project file through the class loader to obtain the class;

[0014] For each class, according to the obtained class name, the attribute information and method information of the class are obtained through the Java reflection mechanism;

[0015] The annotation is matched with each extracted class to obtain other basic information of the class.

[0016] Optionally, the Markdown document includes a plurality of partial documents, each partial document corresponding to an extracted class;

[0017] The method further comprises:

[0018] Generate a directory based on the class name and class description of the extracted class;

[0019] Each extracted class corresponds to a directory in the directory, and each directory corresponding to the extracted class is associated with a portion of the document corresponding to the class.

[0020] Optionally, obtaining annotations by scanning a file includes:

[0021] Traverse the project files to determine the location of the preset comment mark;

[0022] The text at the location of the preset annotation mark is extracted to obtain the annotation.

[0023] Optionally, the obtaining of project path information, Markdown layout information, and HTML style information includes:

[0024] Receive project path information input by the user; or obtain project path information from a preset file;

[0025] Get the Markdown layout information set by the user; or get the default Markdown layout information;

[0026] Get the HTML style information set by the user; or get the default HTML style information.

[0027] Optionally, the method further includes:

[0028] Receive export instructions from users;

[0029] According to the export instruction, the HTML document is exported.

[0030] In a second aspect, the present application provides a document generation device, comprising:

[0031] The acquisition module is used to obtain project path information, Markdown layout information, and HTML style information; and obtain project files according to the project path information;

[0032] An extraction module, used to extract class information from the project file; the class information includes attribute information, method information, and other basic information in the class;

[0033] A document generation module, used to generate a Markdown document according to the Markdown layout information and based on the extracted class information;

[0034] The document conversion module is used to convert the Markdown document into an HTML document according to the HTML style information.

[0035] Optionally, the extraction module is specifically used to:

[0036] Capture annotations through document scanning;

[0037] Dynamically load the JAR package in the project file through the class loader to obtain the class;

[0038] For each class, according to the obtained class name, the attribute information and method information of the class are obtained through the Java reflection mechanism;

[0039] The annotation is matched with each extracted class to obtain other basic information of the class.

[0040] Optionally, the Markdown document includes a plurality of partial documents, each partial document corresponding to an extracted class;

[0041] The device also includes:

[0042] A directory generation module is used to generate a directory based on the class name and class description of the extracted class;

[0043] Each extracted class corresponds to a directory in the directory, and each directory corresponding to the extracted class is associated with a portion of the document corresponding to the class.

[0044] Optionally, when acquiring annotations through file scanning, the extraction module is specifically used to:

[0045] Traverse the project files to determine the location of the preset comment mark;

[0046] The text at the location of the preset annotation mark is extracted to obtain the annotation.

[0047] Optionally, when acquiring the project path information, Markdown layout information, and HTML style information, the acquisition module is specifically used to:

[0048] Receive project path information input by the user; or obtain project path information from a preset file;

[0049] Get the Markdown layout information set by the user; or get the default Markdown layout information;

[0050] Get the HTML style information set by the user; or get the default HTML style information.

[0051] Optionally, the device further includes a document export module, which is used to:

[0052] Receive export instructions from users;

[0053] According to the export instruction, the HTML document is exported.

[0054] In a third aspect, the present application provides an electronic device, comprising: a memory for storing program instructions; and a processor for calling and executing the program instructions in the memory to execute the method described in the first aspect.

[0055] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect is implemented.

[0056] In a fifth aspect, the present application provides a computer program product, including a computer program, which implements the method described in the first aspect when executed by a processor.

[0057] The present application provides a document generation method, device, electronic device and storage medium. The document generation method includes: obtaining project path information, Markdown layout information, and HTML style information; obtaining a project file according to the project path information; extracting class information from the project file; the class information includes attribute information, method information, and other basic information in the class; generating a Markdown document based on the extracted class information according to the Markdown layout information; and converting the Markdown document into an HTML document according to the HTML style information. Extracting project-related development content information from project files in a non-invasive manner will not have any impact on project files, and can be applied to any type of Java project. At the same time, because Markdown layout information and HTML style information can be selected, users are provided with more choices of content and format of development documents, which allows users to generate corresponding development documents completely according to their own needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the technical solutions in the present application or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0059] Figure 1 A schematic diagram of an application scenario provided for this application;

[0060] Figure 2 A flowchart of a document generation method provided in one embodiment of the present application;

[0061] Figure 3 A schematic diagram of a development document provided for an embodiment of the present application;

[0062] Figure 4 A schematic diagram of a directory of development documents provided in one embodiment of the present application;

[0063] Figure 5 A schematic diagram of a document generation process provided by an embodiment of the present application;

[0064] Figure 6 A schematic diagram of a process of obtaining class information provided by an embodiment of the present application;

[0065] Figure 7 A schematic diagram of another document generation process provided by an embodiment of the present application;

[0066] Figure 8 A schematic diagram of the structure of a document generation device provided in one embodiment of the present application;

[0067] Fig. 9 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0068] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0069] The existing development document generation tools on the market, such as Javadoc and XDoc, generally generate development documents by adding annotations to project codes. These tools generally have the following disadvantages:

[0070] 1) Intrusive to the project. XDoc and other tools need to invade the project code, making the tool an integral part of the project and consuming the project's own resources.

[0071] 2) Unable to adapt to various types of Java projects. Many tools can only be applied to a certain type of project and cannot flexibly adapt to different types of Java projects. For example, XDoc is only applicable to Spring series projects and has the disadvantage of weak adaptability to project types.

[0072] 3) Fixed document style. The style of development documents generated by many tools is fixed and may not match user needs, resulting in a poor user experience.

[0073] Therefore, the present application proposes a method for generating development documents without intruding into the project code.

[0074] Figure 1 A schematic diagram of an application scenario provided by this application. Figure 1 As shown, a corresponding development document is generated for a target project. The project file of the target project is stored at a certain address. The server executes the method of the present application, obtains the project file of the project at the address, extracts relevant information such as classes, attributes, methods, comments, etc. from the project file, and generates a corresponding development document based on this information.

[0075] The specific implementation process is described in detail through the following embodiments.

[0076] Figure 2 A flowchart of a document generation method provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the method of this embodiment can be used to generate corresponding development documents for a target project, and the method includes:

[0077] S201. Obtain project path information, Markdown layout information, and HTML style information.

[0078] The project path information refers to the path information of the location of the project file of the project for which the development document is to be generated.

[0079] In some embodiments, the user may store the project path information of the project for which the development document is to be generated in the same file, and the project path information may be obtained by reading the file content.

[0080] In other embodiments, an information configuration interface may be provided to the user, and the project path information may be obtained by obtaining the content input by the user.

[0081] Markdown is a lightweight markup language that allows users to write documents in a plain text format that is easy to read and write. Markdown layout information refers to the relevant development content and its layout in the project files that need to be included in the development document. For example, Figure 3 A schematic diagram of a development document provided in an embodiment of the present application. Figure 3 It can be seen that the development document needs to include the class name (StringUtils), class path information (com.abchina.doc2file.util), class description (description: string tool class), and properties and methods in each class. The properties need to include the property name (TEST_1, TEST_2), property description and default value, and the method needs to include the method name (testString1, testString2), method description, parameters, return value, etc., and they should be laid out in this order.

[0082] In some embodiments, default Markdown layout information can be preset and a corresponding Markdown layout template can be generated. In practical applications, the default Markdown layout information can be obtained by obtaining a Markdown layout template. Of course, this implementation is suitable for situations where the user has no special Markdown layout requirements.

[0083] In other embodiments, a Markdown layout template modification interface may be provided to the user. If the user has special Markdown layout requirements, the Markdown layout template may be modified to obtain a new Markdown layout template. The Markdown layout information set by the user may be obtained by obtaining the new Markdown layout template.

[0084] HTML stands for Hypertext Markup Language. It includes a series of tags that can unify the document format on the Internet, unify the layout and display position of the information in the document, and achieve uniformity. HTML style information refers to the display position of a text in the development document and the font, font size and other information of a text. Figure 3 ,from Figure 3 As you can see, all the text is located on the left side of the page. The class name and class path information are in italics. The properties include the property name, property description, and default value. The method includes the method name, method description, parameters, return value, etc. All are displayed in a box and are displayed in a font size smaller than that of "Properties" and "Methods".

[0085] In some embodiments, default HTML style information can be preset and a corresponding HTML style template can be generated. In practical applications, the default HTML style information can be obtained by obtaining an HTML style template. Of course, this implementation is suitable for situations where the user has no special HTML style requirements.

[0086] In other embodiments, an interface for modifying HTML style templates may be provided to users. If users have special HTML style requirements, they may modify the HTML style templates to obtain new HTML style templates. By obtaining the new HTML style templates, the HTML style information set by the user may be obtained.

[0087] S202: Obtain project files according to project path information.

[0088] After obtaining the project path information, the address indicated by the project path information can be accessed to obtain the project file from the address. The project file can be one or some project files in the target project, and specifically can be some files that the user determines need to share information.

[0089] S203, extracting class information from the project file; the class information includes attribute information, method information, and other basic information in the class.

[0090] After obtaining the project file, the class information is extracted from the project file in a non-invasive manner. The class information mainly includes attribute information, method information and other basic information (such as class name, class path, class description, etc., of course, it can also include other information besides this.)

[0091] S204: Generate a Markdown document according to the Markdown layout information and based on the extracted class information.

[0092] According to the obtained Markdown layout information, one or several items of information among the extracted classes, attributes, methods, and comments are integrated to generate a Markdown document.

[0093] It should be noted that the development content extracted by S203 is not less than the development content involved in the Markdown layout information set by the user. In other words, the development content involved in the Markdown layout information set by the user must be the development content that can be extracted by S203. For example, Figure 3 The Markdown layout information in can be analyzed from development content such as classes, properties, methods, and comments.

[0094] The generated Markdown document is equivalent to a text document that contains all necessary content but without special formatting.

[0095] S205. Convert the Markdown document into an HTML document according to the HTML style information.

[0096] In order to improve the readability of the document, the format of the Markdown document is upgraded based on the obtained HTML style information and converted into a more readable HTML document.

[0097] The document generation method provided in this embodiment includes: obtaining project path information, Markdown layout information, and HTML style information; obtaining project files according to the project path information; extracting classes, properties, methods, and comments from the project files; generating Markdown documents based on the extracted classes, properties, methods, and comments according to the Markdown layout information; and converting the Markdown documents into HTML documents according to the HTML style information. Extracting project-related development content information from project files in a non-invasive manner will not have any impact on the project files, and can be applied to any type of Java projects. At the same time, because Markdown layout information and HTML style information can be selected, users are provided with more choices of content and format of development documents, so that users can generate corresponding development documents completely according to their own needs.

[0098] In some embodiments, the above-mentioned S203 extracts class information from the project file, including: obtaining comments through file scanning; dynamically loading the JAR package in the project file through the class loader to obtain the class; for each class, according to the class name of the obtained class, obtaining the class attribute information and method information through the Java reflection mechanism; matching the comments with each extracted class to obtain other basic information of the class.

[0099] Each class file with a ".java" extension stores the program logic that needs to be executed. These ".java" files are compiled into files with a ".class" extension by the Java compiler. The Java code in the ".java" file is converted into virtual machine instructions in the ".class" file. When a class needs to be used during program execution, the virtual machine will load the ".class" file of this class, create a corresponding class object, and load the class file into the memory of the virtual machine. This process is called class loading. The tool that implements the class loading process is called a class loader. Therefore, the class loader naturally has the ability to obtain classes.

[0100] Java reflection mechanism means that during the program running process, for any class, all the properties and methods of this class can be obtained; for any object, any method and property of it can be called; this function of dynamically obtaining information and dynamically calling object methods is called the reflection mechanism of Java language. Therefore, in Java, as long as the name of a class is given, all the information of the class can be obtained through the reflection mechanism.

[0101] This embodiment can ensure the integrity of code comments and obtain all the attributes and methods in the class.

[0102] The obtaining of annotations through file scanning may include: traversing the project file to determine the location of a preset annotation mark; and extracting the text at the location of the preset annotation mark to obtain the annotation.

[0103] Generally, during the project process, specific comment tags are used to mark comments in the project file, such as " / / ", " / **...* / ", " / *...* / ", etc. By traversing the code in the project file, the location of the comment tag can be determined, and then the text at the corresponding location can be extracted, which is the content of the comment. The content of the comment generally marks the purpose of the class or the purpose of the method in the class, the meaning of the parameter, etc.

[0104] In some embodiments, the Markdown document includes several partial documents, each partial document corresponds to an extracted class; the above-mentioned document generation method also includes: generating a directory based on the class name and class description of the extracted class; wherein each extracted class corresponds to a directory in the directory, and each directory corresponding to the extracted class is associated with the partial document corresponding to the class.

[0105] Specifically, refer to Figure 3 , Figure 3 It is a part of the document in the Markdown document, corresponding to the class "StringUtils", which contains the basic information of the class such as the class name, path, description, and the properties and methods in the class. Figure 4 , Figure 4 This is a schematic diagram of the generated directory. One of the directories, "StringUtils string tool class", corresponds to Figure 3 The "StringUtils" class shown in the figure is associated with the partial document. Specifically, a link can be generated for each class name in the directory, linking to the partial document corresponding to the class.

[0106] By adding a directory, other users can easily access relevant information.

[0107] In some embodiments, the HTML document can also be exported as an offline document. Specifically, an export instruction from a user can be received, and the HTML document can be exported according to the export instruction.

[0108] An export button can be set for the user on the interface. The user triggers the export command by clicking the export button, and the device can export the HTML document.

[0109] Furthermore, multiple export buttons can be set, for example, "Export current page", "Export all documents", "Export target page", etc. can be set at the same time, and users can choose the specific export method according to actual needs.

[0110] In a specific embodiment, Figure 5 As shown in the figure, the basic information in the process of generating development documents is managed through the "configuration file". Among them, "project configuration" is used to configure the basic information of the project, including project path information, etc.; "custom MD layout" is used to configure Markdown layout information; "custom H5 style" is used to configure HTML style information.

[0111] After configuring the basic information, "Read Project Configuration" (i.e., access the address indicated by the project path to obtain the project file) through "Project Scanner". Then, on the one hand, obtain the comments in the project file through "Scan File", and on the other hand, extract the class, class attributes, methods and other information in the project file through "Load Package / Class". Then, through "Match Annotation", match the class with the annotation to determine the description of the attributes and methods of each class and each type of class.

[0112] Through the "Document Manager" "Configure MD Layout" based on the layout information defined in the "Custom MD Layout", the project information scanned by the "Project Scanner" is "Generate MD Document" (Generate Markdown Document).

[0113] Use "Document Manager" to configure H5 style based on the HTML style information defined in "Custom H5 style", and use "MD Document Conversion" to convert the Markdown document into an HTML document based on the configured HTML style.

[0114] With "Online / Offline Documentation" you can choose to generate online HTML documentation (browser) or offline HTML documentation (download).

[0115] It should be noted that Figure 5 The "configuration file" and other modules in the are functional modules abstracted from the method functions. The functions that can be realized refer to the above description. Except for the steps with a clear sequence, the execution order of other steps is not limited. For example, "Configure MD layout" can be executed at the same time as "Configure H5 style" to save overall time.

[0116] Among them, the function of "project scanner" can be realized based on three functions: file scanning + class loader + reflection mechanism. Figure 6 As shown, after obtaining the project file through "reading configuration information", on the one hand, the file scanning function is used to "scan the target file content" (where the target file is the project file) to "check out meaningful content" (i.e. comments) from it; on the other hand, through "building project jar package", the .class files generated after compiling the java file are packaged into a jar package (for external use, the dotted box indicates that this step can be omitted, that is, subsequent processing is directly based on the .class file), and then the class is obtained through "class loader loading", and then the attributes, methods and other information in each class are obtained through "Java reflection mechanism obtaining class information"; finally, through "matching comments and class information", other information in each class is improved.

[0117] This embodiment obtains code comments through file scanning, dynamically loads the project jar package through the class loader to obtain specific package and class information, and then obtains the attributes and methods in the class through the Java reflection mechanism. This method can ensure the integrity of code comments and ensure that all attributes and methods in the class are obtained.

[0118] In addition, the functions of "Configuration File" and "Document Manager" can be referred to Figure 7 .like Figure 7 As shown, after "configuring basic project information", determine "whether to configure MD layout". If it is determined to "configure MD layout information", the user-defined MD layout information will be "applied to MD template"; otherwise, directly "use the default MD template". Then, determine "whether to configure H5 style". If it is determined to "configure H5 style information", the user-defined H5 style information will be "applied to H5 template document"; otherwise, directly "use the default H5 template". Then, "run the tool" to generate the H5 document, and finally you can "view / export the document".

[0119] This solution requires configuration of three configuration files: basic project information, Markdown layout information, and HTML style information. Basic project information must be configured, including the following important information: project address, target package / class address, project jar package address, exported document address, etc. After the user configures the Markdown layout information and HTML style information, this solution will read the configuration information and replace the default layout and style to generate the corresponding online / offline documents.

[0120] Through the solution of this application, users can specify the Java packages / classes, document layout and style, export address, and online / offline access methods involved in the document through self-configuration. This solves the problems of prior art project intrusion, weak project adaptability, and solidification of project output documents.

[0121] Figure 8 A schematic diagram of the structure of a document generation device provided in one embodiment of the present application is shown in FIG. Figure 8 As shown, the document generation device 800 of this embodiment may include: an acquisition module 801 , an extraction module 802 , a document generation module 803 and a document conversion module 804 .

[0122] The acquisition module 801 is used to acquire project path information, Markdown layout information, and HTML style information; and acquire project files according to the project path information;

[0123] Extraction module 802, used to extract class information from the project file; the class information includes attribute information, method information, and other basic information in the class;

[0124] The document generation module 803 is used to generate a Markdown document according to the Markdown layout information and based on the extracted class information;

[0125] The document conversion module 804 is used to convert the Markdown document into an HTML document according to the HTML style information.

[0126] Optionally, the extraction module 802 is specifically used for:

[0127] Capture annotations through document scanning;

[0128] Dynamically load the JAR package in the project file through the class loader to obtain the class;

[0129] For each class, according to the obtained class name, the class attribute information and method information are obtained through the Java reflection mechanism;

[0130] Match the annotations to each extracted class to obtain other basic information of the class.

[0131] Optionally, the Markdown document includes several partial documents, each partial document corresponding to an extracted class;

[0132] The apparatus 800 further comprises:

[0133] A directory generation module 805, used to generate a directory according to the extracted class name and class description;

[0134] Each extracted class corresponds to a directory in the directory, and each directory corresponding to the extracted class is associated with a partial document corresponding to the class.

[0135] Optionally, when the extraction module 802 obtains the annotations through file scanning, it is specifically used to:

[0136] Traverse the project files to determine the location of the preset comment mark;

[0137] The text at the location of the preset annotation mark is extracted to obtain the annotation.

[0138] Optionally, when acquiring the project path information, the Markdown layout information, and the HTML style information, the acquisition module 801 is specifically used to:

[0139] Receive project path information input by the user; or obtain project path information from a preset file;

[0140] Get the Markdown layout information set by the user; or get the default Markdown layout information;

[0141] Get the HTML style information set by the user; or get the default HTML style information.

[0142] Optionally, the apparatus 800 further includes a document export module 806, which is used to:

[0143] Receive export instructions from users;

[0144] Export the HTML document according to the export instructions.

[0145] The device of this embodiment can be used to execute the method of any of the above embodiments. Its implementation principle and technical effects are similar and will not be described in detail here.

[0146] Fig. 9 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application is shown in FIG. Fig. 9 As shown, the electronic device 900 of this embodiment may include:

[0147] The memory 901 is used to store program instructions.

[0148] The processor 902 is used to call and execute the program instructions in the memory 901 to perform the method of any of the above embodiments. The implementation principles and technical effects are similar and will not be repeated here.

[0149] The present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the method of any of the above embodiments is implemented.

[0150] The present application also provides a computer program product, including a computer program, which implements the method of any of the above embodiments when executed by a processor.

[0151] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0152] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A document generation method, characterized in that: include: Get project path information, Markdown layout information, and HTML style information; According to the project path information, obtain the project file; Extracting class information from the project file; the class information includes class name, class path information, class description information, class attribute information, class method information, and other basic information; Generate a Markdown document according to the Markdown layout information and based on the extracted class information; the Markdown layout information is extracted from the class information extracted from the project file; Convert the Markdown document into an HTML document according to the HTML style information; The extracting class information from the project file includes: Traverse the project files to determine the location of the preset comment mark; Extract the text at the location of the preset annotation mark to obtain the annotation; dynamically load the JAR package in the project file through the class loader to obtain the class; wherein the JAR package is obtained by packaging the .class file generated after compiling the java file; For each class, according to the obtained class name, the attribute information and method information of the class are obtained through the Java reflection mechanism; Matching the annotation with each extracted class to obtain other basic information of the class; The Markdown document includes a plurality of partial documents, each partial document corresponding to an extracted class; The method further comprises: Generate a directory based on the class name and class description of the extracted class; Each extracted class corresponds to a directory in the directory, and each directory corresponding to the extracted class is associated with a portion of the document corresponding to the class.

2. The method according to claim 1, characterized in that The obtaining of project path information, Markdown layout information, and HTML style information includes: Receive project path information input by the user; or obtain project path information from a preset file; Get the Markdown layout information set by the user; or get the default Markdown layout information; Get the HTML style information set by the user; or get the default HTML style information.

3. The method according to claim 1, characterized in that Also includes: Receive export instructions from users; According to the export instruction, the HTML document is exported.

4. A document generation device, characterized in that: include: The acquisition module is used to obtain project path information, Markdown layout information, and HTML style information; and obtain project files according to the project path information; An extraction module, used to extract class information from the project file; the class information includes class name, class path information, class description information, class attribute information, method information, and other basic information; A document generation module, used to generate a Markdown document according to the Markdown layout information and based on the extracted class information; the Markdown layout information is extracted from the class information extracted from the project file; A document conversion module, used for converting the Markdown document into an HTML document according to the HTML style information; The extraction module is specifically used to traverse the project file to determine the location of the preset comment mark; extract the text at the location of the preset comment mark to obtain the comment; dynamically load the JAR package in the project file through the class loader to obtain the class; wherein the JAR package is obtained by packaging the .class file generated after the java file is compiled; for each class, according to the obtained class name of the class, obtain the attribute information and method information of the class through the Java reflection mechanism; match the comment with each extracted class to obtain other basic information of the class; The Markdown document includes several partial documents, each of which corresponds to an extracted class; a directory generation module is used to generate a directory based on the class name and description of the extracted class; wherein each extracted class corresponds to a directory in the directory, and each directory corresponding to the extracted class is associated with the partial document corresponding to the class.

5. An electronic device, characterized in that: include: A memory for storing program instructions; A processor is used to call and execute program instructions in the memory to perform the method according to any one of claims 1 to 3.

6. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.

7. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Application programming interface document generation method and device and terminal equipment

    CN110162296A

  • Method for generating enumerated document, device, electronic equipment and storage medium

    CN112799718A