Open NathanReb opened 1 month ago
Hello!
I am an Outreachy applicant and I’m interested in contributing to the project by working on the issue regarding "the detection of addition and removal of class_type_declaration items".
As requested, here’s the screenshot of the api-diff man page:
Could you please assign this issue to me? Thank you!
Yes sure! Let this issue be assigned to you.
This was typoedly linked from a PR. It is not fixed by #92 but by #87.
Could I work on this ? I'd like to learn about OOP in OCaml.
Sure thing!
The current implementation of our API diffing does not handle every type of item that can be defined within a module.
It will compare items that we support, detecting addition, removal and modification of said items. If it fails to detect any such change, it will default back to comparing the whole module using
Includemod.signatures
.Our ultimate goal is to support fine grained diffing of each and every signature items.
To get one step closer, we would like to add detection of the addition and removal of class_type_declaration items.
How to proceed
The diffing logic and representation is found in
lib/diff.ml
.The content of a module is represented as a list even though the order does not matter there. To work around that we first build a map of its content, indexed by pairs of item type and name. We then proceed to compare the two maps we built from the two versions of the module we are diffing. If both map contain a mapping for a given type/name pair, we compare them to try and detect whether it was modified. If only one of the map contains a binding for a given pair, that means that it was either added or removed, based on which map has the binding.
To detect addition/removal of module type declarations, we will have to extend the
item_type
andsig_items
types which are used to build the map mentioned above. These are then used in theextract_items
function that builds the map from the module signature.Finally, the actual diffing logic's entry point is the
Diff.items
function which handles the comparison of the two maps via the merge function (you can read the documentation here).Testing
This should be tested at the library level. You can add a new
tests/api-watch/test_diff_class_type_decl.ml
file where you can write tests for type addition or removal. You can use thetests/api-watch/test_diff.ml
ortests/api-watch/test_diff_module.ml
files as examples on how to write such tests.