Yup, a lot of my work involves open source projects so I have the benefit of being able to go through the authoritative source code myself if need be. Really sucks for stuff like "black box" appliances though.
This is one of those situations where even though I believe a motivated human could do a better job, in practice AI will produce better results because humans just aren't motivated to write good documentation.
But it's a much easier task to have the AI just verify that the documentation is correct. It still has the possibility of error, but with both the documentation and the code, the chances are pretty low.
Basically the idea is that in whatever docstring that you usually add to a function for documentation, you include some special syntax to illustrate an example of how to use that function, you have some tool to extract and run that example. Thus, you become able to catch outdated documentation as a part of your build process.
It's easily one of my favorite things about Python. I can set up some quick-and-dirty tiny functional unit test and keep it in version control with the rest of the code. Personally I like writing my doctests similar to this:
#!/usr/bin/env python3
importdoctestdefis_this_good(thing:str)->bool:"""
Checks if the thing is a good thing.
Doctests are good.
>>> assert is_this_good("doctests")
Facism is not.
>>> assert is_this_good("facism") == False
Being able to drop into the python debugger when an assertion fails from a
doctest is cool, but not something to include in CI/CD
>>> some_bullshit_condition = False
>>> assert some_bullshit_condition, breakpoint()
"""good_things={"doctests","puppies","boobs","world peace"}returnthingingood_thingsdefmain():doctest.testmod()if__name__=="__main__":main()
Oh, so functionally you're just writing your tests directly in your code without a tests.py for the basic stuff. That's really cool, I think I might start integrating it into my codebases too.
View all comments
Show parent comment
47
u/Hollowed-Be-Thy-Name 23h ago
I can't remember a single time I've read documentation and didn't find out it was wrong or outdated.
Probably just confirmation bias, but it happens often enough.