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
Fix single line docstring parsing error #68
Fix single line docstring parsing error #68
Conversation
Thankfully your testing is all automatic, and 1 test failed where Additional changes made
Additional code tested @handcalcs.handcalc(override="long")
def addition3(val1,val2):
"""
My doc string
Line 2 of doc string
"""
c = val1/val2
return c
latex3, vals3 = addition3(1,2)
st.write("3 dashes on line by themselves")
st.latex(latex3) |
textwrap.dedent is also good for stripping leading whitespace in a nice way vs. using lstrip:
using lstrip() loses the indentation - textwrap.dedent will preserve it. |
I don't think keeping the indentation on the doc-string is necessary, because I'll wait to see if Connor wants to integrate |
…urce_to_cell to remove_imports_defs_and_globals
I added testing for the new
elif doc_string:
continue
|
Not too worried about all string literals being a possible doc string right now. I don't think I have ever actually seen anyone do that (but I am sure they are out there). |
Thank you very much, @michaellisitsa! |
Fix single line docstring parsing error
What it fixes
Related to Issue #66 this allows a single line doc-string to be used when using the python decorator.
I read online that Regex needs to be compiled first, which can make it slower than the python string functions I adopted.
Limitations
I decided to keep it simple for my first pull request, in case the maintainer wants to style the code differently.
'''
Testing conducted
pip install streamlit
handcalcs
repopython setup.py install --user
inside the cloned handcalcs directory. see bottom as the installation didn't behave quite rightOutput
Issues installing using
python setup.py install
When running the above script
additionX(val1,val2)
was generating the following console outputs (which I usually don't get when I pip install handcalcs). The latex appears to still work though.