GithubHelp home page GithubHelp logo

Comments (5)

omarkhan avatar omarkhan commented on September 24, 2024

Take a look at the formatDocstring() function in coffeedoc.coffee. It counts the number of leading spaces before each line in the docstring, and assumes the lowest number it finds to be the indentation level. It then removes that many spaces from each line.

This will not work if you use tabs for indentation. I didn't bother putting in code for this as I don't use tabs and wasn't sure how to determine docstring indentation for cases with mixed tabs and spaces etc. If you want to contribute a patch I'll happily merge your code.

from coffeedoc.

raphinesse avatar raphinesse commented on September 24, 2024

Regarding the mixed tabs and spaces issue:
I'd say this should be of no concern as it's generally considered bad practice. What's your opinion on that?

from coffeedoc.

omarkhan avatar omarkhan commented on September 24, 2024

Sure. Then the formatDocstring() function just needs to figure out whether the code uses tabs or spaces, and then count them. Can you write a patch?

from coffeedoc.

raphinesse avatar raphinesse commented on September 24, 2024

Actually I have no experience in working with Node.js. So building, testing etc. would be quite time-consuming for me since I'd have to look up all the stuff.

However if I haven't overlooked anything it should suffice to replace the space with the \s character class in the Regular Expressions on these lines: 149, 156, 157, 160. That would be equivalent to [ \t\r\n] which should be OK since we're never dealing with newlines here. If it sounds safer you could still use [ \t] instead.

The other thing that could be added is a warning when using mixed characters for indentation. But I think I could come up with something for that too...

from coffeedoc.

omarkhan avatar omarkhan commented on September 24, 2024

Looks good. Fixed in 00c52b3

from coffeedoc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.