Giter Site home page Giter Site logo

Comments (7)

progrium avatar progrium commented on June 4, 2024 4

@ingkebil Using declare -f gets you the source of a function, which you can then process as text. Here is a module with this little bit of code that gets us this kind of reflection: https://github.com/gliderlabs/glidergun/blob/master/src/fn.bash

from bashstyle.

elasticdog avatar elasticdog commented on June 4, 2024 3

My preference is style B.

from bashstyle.

progrium avatar progrium commented on June 4, 2024

B, however, I usually have a reflection based description system where I say:

declare desc="This is what my function does"

Just inside the function. I even do this when I don't have that system in place. But if you have a long description, it would make less sense there.

from bashstyle.

shazow avatar shazow commented on June 4, 2024

Do we want to include a full example? Ideally with usage and other kinds of verbose stuff people might have. I've been using this style here https://github.com/shazow/dotfiles/blob/master/helpers.bash

# b does foo by performing baaz
# Example:
#     $ b quux
#     someoutput
b() {
    ...
}

Ideally something that parsing/extracting won't be too hard.

from bashstyle.

progrium avatar progrium commented on June 4, 2024

👍

from bashstyle.

silopolis avatar silopolis commented on June 4, 2024

AFAIC, 'B' too, and going a little further with bashdoc.sh script:

http://wiki.sourcemage.org/bashdoc
https://github.com/eatnumber1/envbot/tree/master/tools/bashdoc

Used to have a bookmark to this script website but can't find it.
This is the first refs DDG returned me and it's not bad to see it used in a
complete bash project.

My 2 cts

Jérémie Tarot
http://about.me/silopolis

from bashstyle.

ingkebil avatar ingkebil commented on June 4, 2024

Sorry for bumping an old thread!

B, however, I usually have a reflection based description system where I say:

declare desc="This is what my function does"

Just inside the function. I even do this when I don't have that system in place. But if you have a long description, it would make less sense there.

I'm not familiar with a 'reflection based description system'. I've googled around, but don't seem to find anything that would enable me to use the desc declared inside a function. How does one go about using this?

from bashstyle.

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.