Giter Site home page Giter Site logo

Comments (12)

moskytw avatar moskytw commented on May 27, 2024

It will be hard to fix, because the insert, select, ... actually are the instances of Query, so the document is written in Sphinx rather than in theirs docstring. You can check the query.rst which is the source of this page and query.py for detail.

It will be nice if you have idea to fix it.

from mosql.

uranusjr avatar uranusjr commented on May 27, 2024

I've had some thought on this too, since mosql's current implementation doesn't play well with bpython and CodeIntel, either. One of the quick 'n' dirty solution I've come up with is (in query.py)

def select(table=None, where=None, **clause_args):
    """docstring goes here"""
    return Query(statement.select, ('table', 'set'))(table, where, **clause_args)

Not pretty, but gets the job done.

from mosql.

moskytw avatar moskytw commented on May 27, 2024

I believe you are kidding me. LOL

from mosql.

uranusjr avatar uranusjr commented on May 27, 2024

Partly, but there isn't really a good solution, is there? :p

Seriously though, the only solution (other than the above one if it can be called that way) I can think of is using metaclass. But Python 2 and 3 have different metaclass syntaxes, and it would cause incompatibility beyond repair.

Bottom line is, it would be really nice to have some kind of inline documentation available, and (personally) I would do some ugly things to get it.

from mosql.

moskytw avatar moskytw commented on May 27, 2024

I won't do so. It is too over to hack the original code just for supporting doc. And we already have the http://mosql.mosky.tw/query.html . :)

from mosql.

lucemia avatar lucemia commented on May 27, 2024

I tried to hack the docstring but still got nothing. I guess there is no good way to do so for now (as far as I know). and the Issue can be marked as Wont Fix for now.
BTW I think @uranusjr provide a possible way, since the interface don't need to expose the implementation.

from mosql.

eugene-eeo avatar eugene-eeo commented on May 27, 2024

Just modify the doc attribute of the function.

from mosql.

eugene-eeo avatar eugene-eeo commented on May 27, 2024

Sorry, I mean to use __doc__.

from mosql.

uranusjr avatar uranusjr commented on May 27, 2024

Setting __doc__ gets you nowhere, unfortunately. Things like mosql.query.insert are implemented as callable instances, and help generates its content by the docstring of their class, which is mosql.util.Query. Run the following and you'll see the problem:

class Foo(object):
    """An example class
    """

foo = Foo()
foo.__doc__ = 'This is an instance'
help(foo)

With that said, you actually got me thinking again. Metaclassing should work:

class BaseFoo(object):
    """An example class
    """

def get_foo(docstring):

    class MetaFoo(type):
        def __new__(cls, name, parents, attrs):
            attrs['__doc__'] = docstring
            return super(MetaFoo, cls).__new__(cls, name, parents, attrs)

    class Foo(object):
        __metaclass__ = MetaFoo

foo = get_foo()
help(foo)

But this stills seems pretty hacky to me, to be honest.

from mosql.

eugene-eeo avatar eugene-eeo commented on May 27, 2024

Make a constructor for the class that does the same thing, assign insert to that constructor and document it.

from mosql.

moskytw avatar moskytw commented on May 27, 2024

Could you give an example? I didn't understand.

from mosql.

moskytw avatar moskytw commented on May 27, 2024

I am going to close this issue. I will refine the Sphinx docs.

from mosql.

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.