Code document updating method and device, computer equipment and readable storage medium

By building a knowledge graph of the code repository, the technical documentation is monitored and updated in real time, solving the problem of synchronizing the code repository and technical documentation. This enables automatic synchronization and highlighting of documentation when code changes occur, reducing manual maintenance costs.

CN121658069APending Publication Date: 2026-03-13CHINA LIFE INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-14
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

In the process of software development and maintenance, there is a problem of synchronizing the code repository with its corresponding technical documentation. This is especially true in rapid iteration models such as agile development and continuous integration, where code changes are frequent and related technical documentation lags behind, causing the documentation to lose its reference value.

Method used

By constructing a knowledge graph of the codebase, code change events can be monitored in real time, and related elements and update strategies can be automatically determined. Based on the knowledge graph, technical documents can be automatically synchronized and updated.

Benefits of technology

It enables real-time synchronization between the code repository and technical documentation, ensuring dynamic linking between the documentation and the code, reducing manual maintenance costs, and improving the reference value and accuracy of the documentation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121658069A_ABST
    Figure CN121658069A_ABST
Patent Text Reader

Abstract

The invention relates to a code document updating method and device, computer equipment and a readable storage medium. The method comprises the steps that under the condition that it is monitored that a code change event exists in a code library, target code elements corresponding to the code change event are obtained; wherein the code change event is an event for updating the target code element; determining at least one associated element corresponding to the target code element based on a relationship between elements in a knowledge graph corresponding to the code library; according to code change data corresponding to the code change event, determining a document updating strategy of a technical document corresponding to the code library; and based on the document updating strategy, updating the target code element in the technical document and the text data corresponding to each associated element. By adopting the method, the corresponding technical document can be automatically and synchronously updated when the code is changed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a method, apparatus, computer device, and readable storage medium for updating code documents. Background Technology

[0002] In the process of software development and maintenance, the problem of synchronizing the code repository with its corresponding technical documentation has long plagued development teams.

[0003] As modern software systems become increasingly complex and codebases expand, traditional methods of maintaining technical documentation are no longer sufficient to meet practical needs. This is especially true in rapidly iterating development models such as agile development and continuous integration, where the frequency of code changes in the codebase increases significantly. Related technical documentation often lags behind code evolution, causing it to gradually lose its reference value, a problem that urgently needs to be addressed. Summary of the Invention

[0004] Therefore, it is necessary to provide a code documentation update method, apparatus, computer equipment, and readable storage medium that can automatically and synchronously update the corresponding technical documentation when the code changes, in order to address the above-mentioned technical problems.

[0005] Firstly, this application provides a method for updating code documentation, including:

[0006] If a code change event is detected in the code repository, the target code element corresponding to the code change event is obtained; where the code change event is an event that updates the target code element.

[0007] Based on the relationships between elements in the knowledge graph corresponding to the code repository, at least one associated element corresponding to the target code element is determined; and,

[0008] Based on the code change data corresponding to the code change event, determine the documentation update strategy for the corresponding technical documentation in the code repository;

[0009] Based on the document update strategy, the text data corresponding to the target code elements and their associated elements in the technical document are updated.

[0010] In one embodiment, the code change data includes change element data and / or change relationship data; correspondingly, based on the code change data corresponding to the code change event, a document update strategy for the technical documentation corresponding to the code repository is determined, including:

[0011] When the code change data only includes the changed element data, the element addition strategy will be used as the document update strategy for the corresponding technical documentation in the code repository;

[0012] When the code change data only includes change relationship data, the relationship modification strategy will be used as the document update strategy for the corresponding technical documentation in the code repository;

[0013] When code changes include changes to element data and changes to relationship data, the element addition strategy and relationship modification strategy are merged into the document update strategy for the corresponding technical documentation in the code repository.

[0014] In one embodiment, based on a document update strategy, the text data corresponding to the target code elements and their associated elements in the technical document are updated, including:

[0015] Obtain the association strength between the target code element and at least one associated element;

[0016] Determine the update order of each associated element based on the association strength;

[0017] Based on the document update strategy, the text data corresponding to the target code elements and their associated elements in the technical document are updated in the order of update; among them, the target code elements are updated first.

[0018] In one embodiment, the method further includes, prior to monitoring code change events in the codebase:

[0019] Extract each element from the codebase and the relationships between them;

[0020] Based on the elements in the codebase, generate nodes in the knowledge graph, and based on the relationships between the elements in the codebase, generate edges between the nodes in the knowledge graph.

[0021] Construct a knowledge graph corresponding to the codebase based on each node and the edges between them.

[0022] In one embodiment, the method further includes, prior to monitoring code change events in the codebase:

[0023] Retrieve text data from the technical documentation corresponding to the code repository;

[0024] Semantic extraction is performed on the text data to determine the technical features corresponding to each text data.

[0025] Based on the technical characteristics of each text data, the correspondence between each text data and the code elements in the code library is determined.

[0026] In one embodiment, after updating the text data corresponding to the target code elements and their associated elements in the technical document based on a document update strategy, the method further includes:

[0027] Display updated text data in technical documents separately.

[0028] In one embodiment, the method further includes:

[0029] When a code change event is detected in the code repository, the elements in the knowledge graph corresponding to the code change event and the relationships between the elements are updated based on the code change data corresponding to the code change event, resulting in an updated knowledge graph.

[0030] Secondly, this application also provides a code documentation updating device, comprising:

[0031] The element acquisition module is used to acquire the target code element corresponding to the code change event when a code change event is detected in the code repository; where the code change event is an event that updates the target code element.

[0032] The element determination module is used to determine at least one associated element corresponding to a target code element based on the relationships between elements in the knowledge graph corresponding to the code repository; and,

[0033] The strategy determination module is used to determine the document update strategy for the corresponding technical documents in the code repository based on the code change data corresponding to the code change event.

[0034] The document update module is used to update the text data corresponding to the target code elements and their associated elements in the technical document based on the document update strategy.

[0035] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0036] If a code change event is detected in the code repository, the target code element corresponding to the code change event is obtained; where the code change event is an event that updates the target code element.

[0037] Based on the relationships between elements in the knowledge graph corresponding to the code repository, at least one associated element corresponding to the target code element is determined; and,

[0038] Based on the code change data corresponding to the code change event, determine the documentation update strategy for the corresponding technical documentation in the code repository;

[0039] Based on the document update strategy, the text data corresponding to the target code elements and their associated elements in the technical document are updated.

[0040] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:

[0041] If a code change event is detected in the code repository, the target code element corresponding to the code change event is obtained; where the code change event is an event that updates the target code element.

[0042] Based on the relationships between elements in the knowledge graph corresponding to the code repository, at least one associated element corresponding to the target code element is determined; and,

[0043] Based on the code change data corresponding to the code change event, determine the documentation update strategy for the corresponding technical documentation in the code repository;

[0044] Based on the document update strategy, the text data corresponding to the target code elements and their associated elements in the technical document are updated.

[0045] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:

[0046] If a code change event is detected in the code repository, the target code element corresponding to the code change event is obtained; where the code change event is an event that updates the target code element.

[0047] Based on the relationships between elements in the knowledge graph corresponding to the code repository, at least one associated element corresponding to the target code element is determined; and,

[0048] Based on the code change data corresponding to the code change event, determine the documentation update strategy for the corresponding technical documentation in the code repository;

[0049] Based on the document update strategy, the text data corresponding to the target code elements and their associated elements in the technical document are updated.

[0050] The aforementioned code documentation update method, apparatus, computer equipment, and readable storage medium, upon detecting a code change event in the code repository, obtain the target code element corresponding to the code change event and, based on the relationships between elements in the knowledge graph corresponding to the code repository, determine at least one associated element corresponding to the target code element; furthermore, based on the code change data corresponding to the code change event, determine a document update strategy for the technical document corresponding to the code repository; and, based on the document update strategy, update the text data corresponding to the target code element and each associated element in the technical document. In this process, by representing the correspondence between code elements in the code repository using a knowledge graph, it is possible to quickly determine the associated data related to the target code element upon detecting a code change event, thereby determining the scope of document modification. Then, based on the code change data, a document update strategy is determined, and the technical document is modified based on the document update strategy and the text modification scope. This enables automatic modification of the technical document and synchronous modification of the code repository and the technical document. Attached Figure Description

[0051] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0052] Figure 1 This is a flowchart illustrating a code documentation update method in one embodiment;

[0053] Figure 2 This is a flowchart illustrating the knowledge graph construction steps in one embodiment;

[0054] Figure 3 This is a flowchart illustrating the steps for determining code-document relationships in one embodiment;

[0055] Figure 4 This is a flowchart illustrating the code documentation update method in another embodiment;

[0056] Figure 5 This is a structural block diagram of a code document updating device in one embodiment;

[0057] Figure 6 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0058] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0059] Before introducing the embodiments of this application, it should be noted that in the current software development process, the following methods and strategies are mainly used for the association and maintenance of code and documentation: 1. Manual annotation association: Developers add specific format annotation marks in the code and extract and generate documents through document generation tools; 2. Version control system hooks: Trigger document update scripts when code is committed; 3. Independent document management system: Store documents and code separately and establish mapping relationships through identifiers such as UUID. These methods mainly have the following problems: (1) Synchronization lag: After code changes, related documents cannot be updated in real time, resulting in documents and code being disconnected; (2) Association breakage: When the code structure undergoes major changes, the existing link relationship is prone to failure; (3) High maintenance cost: It is necessary to manually ensure the consistency between documents and code, which increases the development burden; (4) Lack of semantic association: Most existing methods are based on text matching and cannot understand the deep semantic relationship between code and documents.

[0060] The embodiments of this application aim to achieve dynamic linking between code base and corresponding technical documents by constructing a code knowledge graph. By adopting a bidirectional linking automatic maintenance mechanism and real-time knowledge graph update technology, it ensures that relevant documents can be automatically and synchronously highlighted when the code changes, thus solving the above-mentioned problems.

[0061] In one exemplary embodiment, such as Figure 1 As shown, a code documentation update method is provided, and its application in a code documentation update system is illustrated, including the following steps:

[0062] S110: If a code change event is detected in the code repository, obtain the target code element corresponding to the code change event.

[0063] Among them, the code change event is an event that updates the target code element. The code change event is used to update one or more target code elements.

[0064] The elements include classes, methods, variables, and metadata.

[0065] In this embodiment, the code document update system is equipped with a monitor for real-time or periodic monitoring of code data in the code repository. Furthermore, when the monitor detects a code change event in the code repository, it obtains the target code element that has undergone the code change.

[0066] S120, Based on the relationships between elements in the knowledge graph corresponding to the code base, determine at least one associated element corresponding to the target code element.

[0067] It's understandable that the knowledge graph corresponding to the codebase contains nodes corresponding to each element in the codebase, and the edge relationships between nodes can be understood as the relationships between code elements. Correspondingly, the associated elements corresponding to the target code element can be understood as other code elements in the knowledge graph that have connections to the node corresponding to the target code element.

[0068] Specifically, in this embodiment, the node corresponding to the target code element in the knowledge graph can be determined, and the elements that have a connection relationship with the node can be used as the associated elements corresponding to the target code element.

[0069] S130, Based on the code change data corresponding to the code change event, determine the document update strategy for the technical documents corresponding to the code repository.

[0070] In this context, a code change event can be used to update an element or to update the relationship between elements. Correspondingly, the code change data indicates the purpose of the code change event.

[0071] In one optional implementation, the code change data includes changed element data and / or changed relationship data; correspondingly, if the code change data only includes changed element data, the element addition strategy can be used as the document update strategy for the corresponding technical document in the code repository; if the code change data only includes changed relationship data, the relationship modification strategy can be used as the document update strategy for the corresponding technical document in the code repository; if the code change data includes both changed element data and changed relationship data, the element addition strategy and the relationship modification strategy can be combined as the document update strategy for the corresponding technical document in the code repository.

[0072] For example, the element addition strategy corresponding to the changed element data and the relationship modification strategy corresponding to the changed relationship data are determined in advance, and the document update strategy is determined based on the code change data.

[0073] For example, when the element data is changed to a new element, text data can be added to the technical document based on the changed element data. This text data is used to represent the new element, other elements that are related to the new element, and the relationships between the elements.

[0074] For example, when changing element data to modify element, the text data corresponding to the modified element in the technical document can be modified.

[0075] S140, based on the document update strategy, update the text data corresponding to the target code elements and their associated elements in the technical document.

[0076] In one alternative implementation, text data in the technical document that corresponds to the target code element can be identified, and annotations can be added to the corresponding text data. The annotations are code change data, for example, the annotations are the changed code.

[0077] In another optional implementation, the association strength between the target code element and at least one associated element can be obtained; the update order of each associated element can be determined based on the association strength; and the text data corresponding to the target code element and each associated element in the technical document can be updated according to the update order based on the document update strategy; wherein, the update order of the target code element is the first one.

[0078] For example, the association strength is sorted from high to low to obtain the update order, and the target code element is updated first, followed by the associated elements with high association strength.

[0079] In the aforementioned code documentation update method, upon detecting a code change event in the code repository, the method obtains the target code element corresponding to the code change event and, based on the relationships between elements in the knowledge graph corresponding to the code repository, determines at least one associated element corresponding to the target code element. Furthermore, based on the code change data corresponding to the code change event, it determines the document update strategy for the technical document corresponding to the code repository. Based on the document update strategy, it updates the text data corresponding to the target code element and its associated elements in the technical document. In this process, by using a knowledge graph to represent the correspondence between code elements in the code repository, it can quickly determine the associated data related to the target code element upon detecting a code change event, thereby determining the scope of document modification. Then, based on the code change data, it determines the document update strategy, and based on the document update strategy and the text modification scope, it modifies the technical document, enabling automatic modification of the technical document and synchronous modification of the code repository and the technical document.

[0080] Based on the technical solutions of the above embodiments, this application also provides an optional embodiment. In this optional embodiment, a preliminary step for monitoring code change events in the code repository is described.

[0081] See Figure 2 The knowledge graph construction steps shown include:

[0082] S210, extract each element from the codebase and the relationships between them.

[0083] For example, for a given codebase C, a set of code elements E = {e1, e2, ..., e2} is extracted through static analysis, where each element e i Includes type t i {Classes, methods, variables, ...} and metadata m i Furthermore, the relationships between code elements, such as calls, inheritance, and inclusion, are analyzed to construct a relationship set R={(e i r k e j )|e i e j E,r k {Call, Inheritance, ...}}.

[0084] S220: Generate nodes in the knowledge graph based on the elements in the codebase, and generate edges between nodes in the knowledge graph based on the relationships between the elements in the codebase.

[0085] S230 constructs a knowledge graph corresponding to the codebase based on each node and the edges between them.

[0086] Specifically, the set of code elements E and the set of relations R are transformed into a directed graph G=(V, A), where vertices V=E and arcs A=R, and for each vertex v... i V Add attribute set a i ={t i m i}, thus obtaining the knowledge graph corresponding to codebase C.

[0087] In another alternative implementation, the code in the codebase can be input into a pre-trained graph generation model to obtain the knowledge graph corresponding to the codebase.

[0088] The above embodiments provide a specific method for constructing the knowledge graph corresponding to the code repository, laying the foundation for subsequent updates to the technical documentation corresponding to the code repository.

[0089] Accordingly, when a code change event is detected in the code repository, the elements in the knowledge graph corresponding to the code repository, as well as the relationships between the elements, are updated based on the code change data corresponding to the code change event, to obtain the updated knowledge graph.

[0090] When changing element data to a newly added element, each e can be processed. new ΔC .add Extract metadata m new (e.g., type, location, signature), add a node v to V.new and set attribute a new ={t new m new If e new For items that are children of an existing element (such as methods in a class), an containing edge to the parent node is automatically added. When changing element data to modify the element, each e can be modified... mod ΔC .modify Update node v mod Attribute a mod (e.g., synchronizing comments and call points after renaming a method).

[0091] Based on the technical solutions of the above embodiments, this application also provides an optional embodiment. In this optional embodiment, another preliminary step for monitoring code change events in the code repository is described.

[0092] See Figure 3 The steps for determining code-document relationships shown include:

[0093] S310, retrieve text data from the corresponding technical documentation in the code repository.

[0094] For example, the document set D = {d1, d2, ..., d...} corresponding to the code repository can be... m The data is parsed and extracted to form a set T = {t1, t2, ..., t...}. k}

[0095] S320, Semantic extraction is performed on the text data to determine the technical features corresponding to each text data.

[0096] For example, text data can be input into a semantic extraction model to obtain the technical features corresponding to the text data.

[0097] S330, based on the technical characteristics corresponding to each text data, determines the correspondence between each text data and the code elements in the code library.

[0098] In one alternative implementation, a mapping function f:T→2 can be established. E Map each technical concept ti to a set of related code elements. Furthermore, a link database is constructed, which stores the correspondence between code elements and text data, as well as the strength of the association between them. For example, the link database L = {(t...} i e j w ij )|t i T, e j f(t) i ), w ij [0, 1]}, where t i Represents text data; t represents technical documents; e represents text data. j Indicates a code element; w ij The strength of association is represented by word embeddings, which are used to calculate the text data t. i Description text and code element e j The semantic similarity of naming, comments, and context code is used. Then, for any code element, the text data with the highest similarity is taken as its corresponding technical text.

[0099] The above embodiments provide a specific method for determining the correspondence between code and text data in the corresponding technical documents, laying the foundation for subsequent updates to the technical documents corresponding to the code library.

[0100] Correspondingly, after updating the text data corresponding to the target code elements and their associated elements in the technical document based on the document update strategy, the updated text data in the technical document can be displayed separately, so that technical personnel can more intuitively understand the updates to the code data when viewing it.

[0101] Based on the technical solutions of the above embodiments, this application also provides an optional embodiment. In this optional embodiment, the code documentation update method provided by this application is described in detail.

[0102] See Figure 4 The code documentation update methods shown include:

[0103] S401A extracts each element from the codebase and the relationships between them;

[0104] For example, for a given codebase C, a set of code elements E={e1, e2, ..., e3} is extracted through static analysis. n}, where each element e i Includes type t i {Classes, methods, variables, ...} and metadata m i Furthermore, analyze the relationships such as calls, inheritance, and inclusion among code elements, and construct a relationship set R={(e i r k e j )|e i e j E,r k {Call, Inheritance, ...}};

[0105] S402A generates nodes in the knowledge graph based on the elements in the code library, and generates edges between nodes in the knowledge graph based on the relationships between the elements in the code library.

[0106] S403A constructs a knowledge graph corresponding to the code base based on each node and the edges between each node;

[0107] For example, the set of code elements E and the set of relations R are transformed into a directed graph G=(V, A), where vertices V=E, arcs A=R, and for each vertex v i V Add attribute set a i ={t i m i}, thus obtaining the knowledge graph corresponding to codebase C;

[0108] S401B, retrieve text data from the corresponding technical documentation in the code repository;

[0109] For example, the document set D = {d1, d2, ..., d...} corresponding to the code repository can be... m The data is parsed and extracted to form a set T = {t1, t2, ..., t...}. k};

[0110] S402B performs semantic extraction on text data to determine the technical features corresponding to each piece of text data;

[0111] S403B, based on the technical characteristics corresponding to each text data, determines the correspondence between each text data and the code elements in the code library;

[0112] For example, a mapping function f:T→2 can be established. E Map each technical concept ti to a set of related code elements. Furthermore, a link database is constructed, which stores the correspondence between code elements and text data, as well as the strength of the association between them. For example, the link database L = {(t...} i e j w ij )|t i T, e j f(t) i ), w ij [0, 1]}, where t i Represents text data; t represents technical documents; e represents text data. j Indicates a code element; w ijThe strength of association is represented by word embeddings, which are used to calculate the text data t. i Description text and code element e j The semantic similarity of naming, comments, and context code is used. Then, for any code element, the text data with the highest similarity is taken as its corresponding technical text.

[0113] S404, based on the correspondence between text data and code elements in the code library, determine the correspondence between text data and nodes in the knowledge graph;

[0114] S405, when a code change event is detected in the code repository, obtain the target code element corresponding to the code change event;

[0115] Among them, the code change event is an event that updates the target code element;

[0116] For example, monitor the change flow ΔC of codebase C to identify the set of change elements. ;

[0117] S406, Based on the relationships between elements in the knowledge graph corresponding to the code base, determine at least one associated element corresponding to the target code element;

[0118] For each e' E' performs a breadth-first search in the knowledge graph G to obtain the set of affected elements (i.e., related elements). ;

[0119] S407, Determine the document update strategy for the corresponding technical documents in the code repository based on the code change data corresponding to the code change event;

[0120] For each e N(e'), querying the inverted index to retrieve related documents: {t|(t, e, w) L} triggers a document update notification;

[0121] At the same time, the elements in the knowledge graph corresponding to the code library, as well as the relationships between the elements, are updated to obtain the updated knowledge graph;

[0122] Specifically, when the code change data only includes changed element data, the element addition strategy is used as the document update strategy for the corresponding technical documentation of the code repository; when the code change data only includes changed relationship data, the relationship modification strategy is used as the document update strategy for the corresponding technical documentation of the code repository; when the code change data includes both changed element data and changed relationship data, the element addition strategy and the relationship modification strategy are combined as the document update strategy for the corresponding technical documentation of the code repository.

[0123] S408, Update the text data corresponding to the target code elements and their associated elements in the technical document according to the update order;

[0124] Among them, the update order of the target code element is the first one;

[0125] S409, distinguish and display updated text data in technical documents.

[0126] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.

[0127] Based on the same inventive concept, this application also provides a code document updating apparatus for implementing the code document updating method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more code document updating apparatus embodiments provided below can be found in the limitations of the code document updating method described above, and will not be repeated here.

[0128] In one exemplary embodiment, such as Figure 5 As shown, a code document updating device is provided, including: an element acquisition module 510, an element determination module 520, a strategy determination module 530, and a document updating module 540, wherein:

[0129] The element acquisition module 510 is used to acquire the target code element corresponding to the code change event when a code change event is detected in the code repository; wherein, the code change event is an event that updates the target code element;

[0130] Element determination module 520 is used to determine at least one associated element corresponding to a target code element based on the relationships between elements in the knowledge graph corresponding to the code repository; and,

[0131] The strategy determination module 530 is used to determine the document update strategy for the corresponding technical documents in the code repository based on the code change data corresponding to the code change event.

[0132] The document update module 540 is used to update the text data corresponding to the target code elements and their associated elements in the technical document based on the document update strategy.

[0133] In one embodiment, the code change data includes changed element data and / or changed relationship data; correspondingly, the strategy determination module 530 includes a first determination unit, configured to use the element addition strategy as the document update strategy for the corresponding technical document of the code repository when the code change data only includes changed element data; a second determination unit, configured to use the relationship modification strategy as the document update strategy for the corresponding technical document of the code repository when the code change data only includes changed relationship data; and a third determination unit, configured to combine the element addition strategy and the relationship modification strategy as the document update strategy for the corresponding technical document of the code repository when the code change data includes both changed element data and changed relationship data.

[0134] In one embodiment, the document update module 540 includes a first acquisition unit for acquiring the association strength between a target code element and at least one associated element; a fourth determination unit for determining the update order of each associated element based on the association strength; and an update unit for updating the text data corresponding to the target code element and each associated element in the technical document according to the update order based on the document update strategy; wherein the update order of the target code element is the first one.

[0135] In one embodiment, the code document update device further includes a graph construction module, used to extract each element in the code library and the relationship between each element; generate nodes in the knowledge graph based on each element in the code library, and generate edges between each node in the knowledge graph based on the relationship between each element in the code library; and construct the knowledge graph corresponding to the code library based on each node and the edges between each node.

[0136] In one embodiment, the code document updating device further includes a relationship building module, used to obtain text data from the technical documents corresponding to the code library; perform semantic extraction on the text data to determine the technical features corresponding to each text data; and determine the correspondence between each text data and code elements in the code library based on the technical features corresponding to each text data.

[0137] In one embodiment, the document update module 540 further includes a display unit, which is used to distinguish and display the updated text data in the technical document after updating the text data corresponding to the target code elements and each associated element in the technical document based on the document update strategy.

[0138] In one embodiment, the code document update device further includes a graph update module, which, upon detecting a code change event in the code repository, updates the elements in the knowledge graph corresponding to the code repository and the relationships between the elements based on the code change data corresponding to the code change event, thereby obtaining an updated knowledge graph.

[0139] Each module in the aforementioned code document update device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0140] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a code document update method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0141] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0142] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0143] If a code change event is detected in the code repository, the target code element corresponding to the code change event is obtained; where the code change event is an event that updates the target code element.

[0144] Based on the relationships between elements in the knowledge graph corresponding to the code repository, at least one associated element corresponding to the target code element is determined; and,

[0145] Based on the code change data corresponding to the code change event, determine the documentation update strategy for the corresponding technical documentation in the code repository;

[0146] Based on the document update strategy, the text data corresponding to the target code elements and their associated elements in the technical document are updated.

[0147] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0148] When the code change data only includes the changed element data, the element addition strategy will be used as the document update strategy for the corresponding technical documentation in the code repository;

[0149] When the code change data only includes change relationship data, the relationship modification strategy will be used as the document update strategy for the corresponding technical documentation in the code repository;

[0150] When code changes include changes to element data and changes to relationship data, the element addition strategy and relationship modification strategy are merged into the document update strategy for the corresponding technical documentation in the code repository.

[0151] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0152] Obtain the association strength between the target code element and at least one associated element;

[0153] Determine the update order of each associated element based on the association strength;

[0154] Based on the document update strategy, the text data corresponding to the target code elements and their associated elements in the technical document are updated in the order of update; among them, the target code elements are updated first.

[0155] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0156] Extract each element from the codebase and the relationships between them;

[0157] Based on the elements in the codebase, generate nodes in the knowledge graph, and based on the relationships between the elements in the codebase, generate edges between the nodes in the knowledge graph.

[0158] Construct a knowledge graph corresponding to the codebase based on each node and the edges between them.

[0159] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0160] Retrieve text data from the technical documentation corresponding to the code repository;

[0161] Semantic extraction is performed on the text data to determine the technical features corresponding to each text data.

[0162] Based on the technical characteristics of each text data, the correspondence between each text data and the code elements in the code library is determined.

[0163] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0164] Display updated text data in technical documents separately.

[0165] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0166] When a code change event is detected in the code repository, the elements in the knowledge graph corresponding to the code change event and the relationships between the elements are updated based on the code change data corresponding to the code change event, resulting in an updated knowledge graph.

[0167] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0168] If a code change event is detected in the code repository, the target code element corresponding to the code change event is obtained; where the code change event is an event that updates the target code element.

[0169] Based on the relationships between elements in the knowledge graph corresponding to the code repository, at least one associated element corresponding to the target code element is determined; and,

[0170] Based on the code change data corresponding to the code change event, determine the documentation update strategy for the corresponding technical documentation in the code repository;

[0171] Based on the document update strategy, the text data corresponding to the target code elements and their associated elements in the technical document are updated.

[0172] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0173] When the code change data only includes the changed element data, the element addition strategy will be used as the document update strategy for the corresponding technical documentation in the code repository;

[0174] When the code change data only includes change relationship data, the relationship modification strategy will be used as the document update strategy for the corresponding technical documentation in the code repository;

[0175] When code changes include changes to element data and changes to relationship data, the element addition strategy and relationship modification strategy are merged into the document update strategy for the corresponding technical documentation in the code repository.

[0176] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0177] Obtain the association strength between the target code element and at least one associated element;

[0178] Determine the update order of each associated element based on the association strength;

[0179] Based on the document update strategy, the text data corresponding to the target code elements and their associated elements in the technical document are updated in the order of update; among them, the target code elements are updated first.

[0180] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0181] Extract each element from the codebase and the relationships between them;

[0182] Based on the elements in the codebase, generate nodes in the knowledge graph, and based on the relationships between the elements in the codebase, generate edges between the nodes in the knowledge graph.

[0183] Construct a knowledge graph corresponding to the codebase based on each node and the edges between them.

[0184] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0185] Retrieve text data from the technical documentation corresponding to the code repository;

[0186] Semantic extraction is performed on the text data to determine the technical features corresponding to each text data.

[0187] Based on the technical characteristics of each text data, the correspondence between each text data and the code elements in the code library is determined.

[0188] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0189] Display updated text data in technical documents separately.

[0190] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0191] When a code change event is detected in the code repository, the elements in the knowledge graph corresponding to the code change event and the relationships between the elements are updated based on the code change data corresponding to the code change event, resulting in an updated knowledge graph.

[0192] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:

[0193] If a code change event is detected in the code repository, the target code element corresponding to the code change event is obtained; where the code change event is an event that updates the target code element.

[0194] Based on the relationships between elements in the knowledge graph corresponding to the code repository, at least one associated element corresponding to the target code element is determined; and,

[0195] Based on the code change data corresponding to the code change event, determine the documentation update strategy for the corresponding technical documentation in the code repository;

[0196] Based on the document update strategy, the text data corresponding to the target code elements and their associated elements in the technical document are updated.

[0197] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0198] When the code change data only includes the changed element data, the element addition strategy will be used as the document update strategy for the corresponding technical documentation in the code repository;

[0199] When the code change data only includes change relationship data, the relationship modification strategy will be used as the document update strategy for the corresponding technical documentation in the code repository;

[0200] When code changes include changes to element data and changes to relationship data, the element addition strategy and relationship modification strategy are merged into the document update strategy for the corresponding technical documentation in the code repository.

[0201] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0202] Obtain the association strength between the target code element and at least one associated element;

[0203] Determine the update order of each associated element based on the association strength;

[0204] Based on the document update strategy, the text data corresponding to the target code elements and their associated elements in the technical document are updated in the order of update; among them, the target code elements are updated first.

[0205] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0206] Extract each element from the codebase and the relationships between them;

[0207] Based on the elements in the codebase, generate nodes in the knowledge graph, and based on the relationships between the elements in the codebase, generate edges between the nodes in the knowledge graph.

[0208] Construct a knowledge graph corresponding to the codebase based on each node and the edges between them.

[0209] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0210] Retrieve text data from the technical documentation corresponding to the code repository;

[0211] Semantic extraction is performed on the text data to determine the technical features corresponding to each text data.

[0212] Based on the technical characteristics of each text data, the correspondence between each text data and the code elements in the code library is determined.

[0213] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0214] Display updated text data in technical documents separately.

[0215] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0216] When a code change event is detected in the code repository, the elements in the knowledge graph corresponding to the code change event and the relationships between the elements are updated based on the code change data corresponding to the code change event, resulting in an updated knowledge graph.

[0217] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0218] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0219] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0220] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for updating code documentation, characterized in that, The method includes: If a code change event is detected in the code repository, the target code element corresponding to the code change event is obtained; wherein, the code change event is an event that updates the target code element; Based on the relationships between elements in the knowledge graph corresponding to the code repository, at least one associated element corresponding to the target code element is determined; and, Based on the code change data corresponding to the code change event, determine the document update strategy for the technical documentation corresponding to the code repository; Based on the document update strategy, the text data corresponding to the target code elements and each associated element in the technical document are updated.

2. The method according to claim 1, characterized in that, The code change data includes changed element data and / or changed relationship data; correspondingly, determining the document update strategy for the technical documents corresponding to the code repository based on the code change data corresponding to the code change event includes: When the code change data only includes the changed element data, the element addition strategy will be used as the document update strategy for the corresponding technical documentation of the code repository; When the code change data only includes the change relationship data, the relationship modification strategy will be used as the document update strategy for the technical documentation corresponding to the code repository; When the code change data includes the change element data and the change relationship data, the element addition strategy and the relationship modification strategy are combined as the document update strategy for the technical documents corresponding to the code repository.

3. The method according to claim 1, characterized in that, The step of updating the text data corresponding to the target code elements and each associated element in the technical document based on the document update strategy includes: Obtain the association strength between the target code element and the at least one associated element; Based on the correlation strength, determine the update order of each of the correlated elements; Based on the document update strategy, the text data corresponding to the target code elements and each associated element in the technical document are updated according to the update order; wherein, the update order of the target code elements is the first one.

4. The method according to any one of claims 1-3, characterized in that, Before monitoring code change events in the codebase, the method further includes: Extract each element from the code library and the relationships between the elements; Based on the elements in the code library, nodes in the knowledge graph are generated, and based on the relationships between the elements in the code library, edges between the nodes in the knowledge graph are generated. Based on each node and the edges between nodes, construct the knowledge graph corresponding to the code library.

5. The method according to any one of claims 1-3, characterized in that, Before monitoring code change events in the codebase, the method further includes: Obtain the text data from the technical documentation corresponding to the code repository; Semantic extraction is performed on the text data to determine the technical features corresponding to each piece of text data; Based on the technical features corresponding to each of the text data, the correspondence between each of the text data and the code elements in the code library is determined.

6. The method according to claim 5, characterized in that, After updating the text data corresponding to the target code element and each associated element in the technical document based on the document update strategy, the method further includes: The updated text data in the technical document will be displayed separately.

7. The method according to any one of claims 1-3, characterized in that, The method further includes: When a code change event is detected in the code repository, the elements in the knowledge graph corresponding to the code repository and the relationships between the elements are updated based on the code change data corresponding to the code change event, resulting in an updated knowledge graph.

8. A code document updating device, characterized in that, The device includes: The element acquisition module is used to acquire the target code element corresponding to the code change event when a code change event is detected in the code repository; wherein, the code change event is an event that updates the target code element; The element determination module is used to determine at least one associated element corresponding to the target code element based on the relationships between elements in the knowledge graph corresponding to the code library; and, The strategy determination module is used to determine the document update strategy for the technical documents corresponding to the code repository based on the code change data corresponding to the code change event. The document update module is used to update the text data corresponding to the target code elements and each of the associated elements in the technical document based on the document update strategy.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1-7.