A powerful CLI for automatic software project documentation generation, compatible with multiple languages and technologies. Simplify and keep your documentation up-to-date with ease.
MIT License
2
stars
1
forks
source link
Refactor metadata storage to use hashes instead of dates #9
Using timestamps (lastModified and lastDocumented) leads to issues where trivial actions, such as saving a file in an editor (e.g., pressing Command + S in VSCode without any actual changes), update the lastModified timestamp. This causes unnecessary regeneration of documentation, which can be inefficient for larger projects.
Proposed Solution:
To avoid unnecessary documentation generation and make the metadata system more accurate, we propose replacing both lastModified and lastDocumented timestamps with hashes of the file content. By comparing these hashes, we can determine if the content has truly changed, reducing false positives for documentation regeneration.
New Metadata Format:
The new metadata.json structure will store two hashes:
documentedHash: The hash of the file content at the time the documentation was last generated.
currentHash: The current hash of the file content, used to determine if it has changed since the last documentation.
Accuracy: This change ensures that documentation is only regenerated when there are actual content changes, not when timestamps are modified by trivial actions like saving the file.
Efficiency: The system becomes more efficient by avoiding unnecessary processing, especially in large projects with many files.
Consistency: Using hashes for both documentedHash and currentHash ensures a consistent and content-based approach to detecting changes.
Scalability: As projects grow, this method scales better than relying on timestamps, reducing the computational overhead for large-scale documentation tasks.
Implementation Steps:
Replace the use of lastModified with currentHash in the metadata.json file.
Replace the use of lastDocumented with documentedHash in the metadata.json file.
Implement a hash generation function (e.g., using SHA-256 or MD5) to compute the content-based hashes for each file.
Modify the comparison logic to use the hashes (documentedHash vs currentHash) instead of timestamps to decide when to regenerate documentation.
Ensure backward compatibility for older metadata formats, if necessary.
This change will enhance the precision and efficiency of Docuforge's documentation generation process, especially for users working with large or frequently edited codebases.
Refactor Metadata Storage to Use Hashes Instead of Dates
Current Behavior:
At present, Docuforge stores metadata about each documented file in a
metadata.json
file, which includes two properties:lastDocumented
: A timestamp representing when the file was last documented.lastModified
: A timestamp representing the last time the file was modified.Example of the current format:
Problem:
Using timestamps (
lastModified
andlastDocumented
) leads to issues where trivial actions, such as saving a file in an editor (e.g., pressingCommand + S
in VSCode without any actual changes), update thelastModified
timestamp. This causes unnecessary regeneration of documentation, which can be inefficient for larger projects.Proposed Solution:
To avoid unnecessary documentation generation and make the metadata system more accurate, we propose replacing both
lastModified
andlastDocumented
timestamps with hashes of the file content. By comparing these hashes, we can determine if the content has truly changed, reducing false positives for documentation regeneration.New Metadata Format:
The new
metadata.json
structure will store two hashes:documentedHash
: The hash of the file content at the time the documentation was last generated.currentHash
: The current hash of the file content, used to determine if it has changed since the last documentation.Example of the updated format:
Benefits:
documentedHash
andcurrentHash
ensures a consistent and content-based approach to detecting changes.Implementation Steps:
lastModified
withcurrentHash
in themetadata.json
file.lastDocumented
withdocumentedHash
in themetadata.json
file.documentedHash
vscurrentHash
) instead of timestamps to decide when to regenerate documentation.This change will enhance the precision and efficiency of Docuforge's documentation generation process, especially for users working with large or frequently edited codebases.