Git Product home page Git Product logo

Comments (11)

sils avatar sils commented on July 22, 2024

@smfn3321 waiting for your opinion here

from coala.

sils avatar sils commented on July 22, 2024

@cw1 your's is valued too

from coala.

sils avatar sils commented on July 22, 2024

This would solve how the use finds out about what the bear is capable of so I'm in favor of it. I'm actually thinking about redesigning our bear architecture a bit. Imagine a bear developer could just write his object as:

class SpaceConsistencyBear(LocalBear):
    def run_bear(self, filename, file, tab_width, allow_trailing_spaces=False):
        pass  # ok we'll want to do something here but thats irrelevant for this example

We then could analyze the signature of this function with inspect.getfullargspec(some_bear.run_bear), thus we could get the settings for the bear and he doesn't have to deal with the settings dict. Furthermore we can extrapolate the needed settings (which is the names of the parameters after, excluding, file) and the minimal_needed_settings. Maybe we could even get a help text from the documentation comment.

from coala.

 avatar commented on July 22, 2024

Your last comment sounds good. Is this the way we can produce a help massage for the user for any giving bear? What kind of syntax would you like to prefer for the documentation comment?

from coala.

sils avatar sils commented on July 22, 2024

usual doc comment like we use all day long in coala.

from coala.

sils avatar sils commented on July 22, 2024

first draft of documentation parser is here: https://github.com/sils1297/coala/blob/wip/extract_needed_params/coalib/parsing/DocumentationCommentParser.py
I'm open to suggestions for simplifications.

from coala.

sils avatar sils commented on July 22, 2024

interesting:

>>> def test(var1, var2: test="t"):
...   pass
... 
>>> getfullargspec(test)
FullArgSpec(args=['var1', 'var2'], varargs=None, varkw=None, defaults=('t',), kwonlyargs=[], kwonlydefaults=None, annotations={'var2': <function test at 0x7f5c45a6fc80>})

from coala.

sils avatar sils commented on July 22, 2024

it works:

>>> from coalib.settings.FunctionMetadata import FunctionMetadata
>>> def test(p1, p2="test", p3=5):
...   """
...   tests something
... 
...   :param p2: its a test value
...   :return nothing.
...   """
...   pass
... 
>>> fm=FunctionMetadata.from_function(
... test)
>>> fm.name
'test'
>>> fm.desc
'tests something'
>>> fm.retval_desc
'nothing.'
>>> fm.non_optional_params
{'p1': 'No description given.'}
>>> fm.optional_params
{'p2': "its a test value (Optional, defaults to 'test'.)", 'p3': "No description given. (Optional, defaults to '5'.)"}

from coala.

sils avatar sils commented on July 22, 2024

began implementation on #150

from coala.

sils avatar sils commented on July 22, 2024

we now have this implemented in the SettingsCreatable, will migrate this to the bears soon. However we'll need code duplication avoidance strategies for this, I don't wanna copy it.

from coala.

sils avatar sils commented on July 22, 2024
lasse@lsmobfed21 ~/prog/gnome/srcn/gnome-boxes (git)-[master] % coala
Please enter a value for the setting "UseSpaces" (('True if spaces are to be used instead of tabs.', <class 'bool'>)) needed by SpaceConsistencyBear:

Works on #150. Outputter needs to be adjusted a bit though but Fabians creating the ConsoleOutputter from scratch anyway.

from coala.

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.