google / mathsteps

Step by step math solutions for everyone
https://socratic.org
Apache License 2.0
2.12k stars 275 forks source link

Create a section in README for API docs or put em in Wiki section #98

Closed karuppiah7890 closed 7 years ago

karuppiah7890 commented 7 years ago

I didn't know how to use the mathsteps.solveEquation() function. And the README is misleading, as if we just have to change mathsteps.simplifyExpression() to mathsteps.solveEquation() to solve an equation. Finally I had to see some tests and understand how to use the API and ended up coding this small piece of code to see how the lib works

const mathsteps = require('mathsteps');

const steps = mathsteps.solveEquation('2x + 3x = 35');

console.log(steps[steps.length-1].newEquation.print());

I personally feel there should be documentation on API usage

evykassirer commented 7 years ago

Very much agreed! It should go in the README.

I'll try to get this done this weekend, or you could add it if you're interested :)

evykassirer commented 7 years ago

(let me know if you want to do it and I'll leave it to you)

karuppiah7890 commented 7 years ago

I am new to the repository. I need some guidance on this. And it's API documentation, I think people who created the API should do it, or help me do it. But the latter is kind of double work in this case, no ?

evykassirer commented 7 years ago

I don't mind double work if you're interested in working on it (always happy to support someone contributing to mathsteps!) but am also quite fine to do it on my own - just wanted to give you the option :)

karuppiah7890 commented 7 years ago

Okay! Let me help :smile:

karuppiah7890 commented 7 years ago

We can discuss here or in gitter.im and I am in India, UTC+05:30 time zone.

karuppiah7890 commented 7 years ago

It's night now, for me. We can discuss tomorrow!

evykassirer commented 7 years ago

goodnight! 🌃

oo I was going to make a gitter for mathsteps! I'm so glad you suggested it too.

I'm thinking something very similar to the existing expression example in the README, just add one for equations

e.g. building on your example above

const mathsteps = require('.');

const steps = mathsteps.solveEquation('2x + 3x = 35');

console.log(steps);
steps.forEach(step => {
    // e.g. before change: 2x + 3x = 35
    console.log("before change: " + step.oldEquation.print());
    // e.g. change: SIMPLIFY_LEFT_SIDE
    console.log("change: " + step.changeType);
    // e.g. after change: 5x = 35
    console.log("after change: " + step.newEquation.print());
    // e.g. # of substeps: 2
    console.log("# of substeps: " + step.substeps.length);
});

what do you think?

karuppiah7890 commented 7 years ago

Pretty neat code! @evykassirer :smile:

karuppiah7890 commented 7 years ago

Do add this one as an example for equations ! :smile: Just remove the console.log(steps) line since it puts up lots of clumsy values. The forEach function part shows em in a neat manner.

evykassirer commented 7 years ago

oh yes! I meant to take that line out oooops.

Do you want to make the pull request that adds this example?

karuppiah7890 commented 7 years ago

Sure! :+1:

karuppiah7890 commented 7 years ago

I created a separate issue for the equation solving example. #102 And created a PR #103 for the same

evykassirer commented 7 years ago

great! would you like to see more thorough API docs too? or do you think the example you added gives enough information (which would mean we can close this issue)

karuppiah7890 commented 7 years ago

I think a more thorough API documentation is needed since there are some more functionalities, like substeps that has some information same as steps. But it's not mentioned and we can't just assume that steps and substeps are of same type. So, it's good if we provide this and more info in the API docs. We can keep it small and simple!

evykassirer commented 7 years ago

sweet, I think it should go in the wiki #66

karuppiah7890 commented 7 years ago

Cool, so shall we close this issue ? or just keep it open till we add docs Wiki ?

And woah, Wiki list has lots of stuff, it can help contributors to get familiar with the code base :+1: and contribute with more ease!

evykassirer commented 7 years ago

eh, let's just close this issue, and have it part of the wiki issue instead.

yeah! I'm excited about the wiki 👍