-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Tests for examples in embedded docs #3413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
OK, I checked out the branch and put an error in an example, and indeed the test failed. The code looks fine. So my only question before merging this is that it only runs the check for identifiers in embeddedDocs -- that's OK, we could put the test elsewhere that there is embeded documentation for every identifier callable from the expression evaluator -- but then it gives an identifier foo a pass if |
Nice catch! Previously I was checking on Fixed it. |
Also if we check for
|
Thanks for the quick update.
These are not really intended to be called by clients of the package, and so it's OK for them to be undocumented, and they can be recorded as such.
These should definitely be documented; I will leave it up to @josdejong whether he wants the addition of documentation to be part of this PR, and whether he wants to add a check that everything is documented besides exceptions like the above.
I am less familiar with these so I will have to defer to @josdejong whether they are in the first or second category above. I think they have to do with JSON encoding and decoding. |
Thanks David, this is nice! I made one inline comment. About the list with failing functions: Glen is right:
I think the PR is small enough to directly add the missing documentation, I can help with that if needed. |
Hi, thanks for the review. Thanks Jos, please help me with the documentation for Just a few comments:
|
I would consider this a bug in the parser, given that Should I file a separate bug for this? I could address it in #3423, for example. Alternatively, I should also point out that if a proposal along the lines of #3379 were adopted, it would also totally fix this, in that we would no longer need to consider |
As a reference, there was some discussion about it at #1905. |
Ah, that's very helpful. I didn't realize that |
Hi, this is ready for review. I included a new test to validate that the "see also" contains only valid names and doesn't contain the name of the current doc. |
While working on it I found a similar case with At this point I'm not addressing either case, just using double quotes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality looks good, comments mostly on docs and comments
Hi Glen, thanks for your review. Most descriptions I just copied them from the jsdcos and simplified a bit for the embedded docs. But I agree with your comments so fixed both, the jsdocs and the embedded docs. I think all your comments are addressed. Also passed some of the expressions from syntax to expression to be more consistent with the jsdocs. |
Just addressed an edge case for names that should have embedded docs but their examples are expected to fail. |
Oops, look like I gave you some bad advice -- I guess Set.difference is not yet implemented in some of the Node versions mathjs is still intended to run on. So I guess you'll need to see what is available in Node 18 as far as Sets go and re-evaluate whether, if you limit to that portion of the Set api, it's worth using Sets at all. My apologies -- on most of my projects, we always just run in the latest greatest, but mathjs has broader aims than that. |
OK, as far as I can see, this is ready to merge. I only didn't because I am unsure whether testing-only PRs get a HISTORY entry. @josdejong please let me know, and/or feel free to merge this yourself. |
Thanks Glen, I also have a version ready that uses Set that doesn't use new features. I can't decide between both, but I think both would work. Using arrays and using Sets. It looks like this. // Add names to the skipDocs array if they are not meant to have embedded docs
const skipDocs = new Set(['import', 'addScalar', 'divideScalar', 'equalScalar', 'multiplyScalar',
'subtractScalar', 'apply', 'replacer', 'reviver'])
// Add names to skipExamples if their examples in the embedded docs contain acceptable errors
const skipExamples = new Set([])
const allTestDocs = new Set([
...Object.keys(embeddedDocs),
...Object.keys(math.expression.mathWithTransform)
])
const testDocs = new Set()
allTestDocs.forEach(name => {
if (!skipDocs.has(name)){
testDocs.add(name)
}
})
const testExamples = new Set()
testDocs.forEach(name => {
if (!skipExamples.has(name)){
testExamples.add(name)
}
}) |
I have no further changes planned, please ignore my previous comment. |
All still seems fine, so my last comment stands |
Thanks @dvd101x! @gwhitney when I just do some refactoring or adding tests, I do not add an entry in the HISTORY.md for that. But if others contribute I find it important to give them credit. And in this case David also improved the embedded docs: added documentation for |
Hi, this includes tests for the examples of the embedded docs according to #3391