Comments (12)
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.
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.
I believe you are kidding me. LOL
from mosql.
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.
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.
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.
Just modify the doc attribute of the function.
from mosql.
Sorry, I mean to use __doc__
.
from mosql.
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.
Make a constructor for the class that does the same thing, assign insert to that constructor and document it.
from mosql.
Could you give an example? I didn't understand.
from mosql.
I am going to close this issue. I will refine the Sphinx docs.
from mosql.
Related Issues (20)
- Port MoSQL to Python 3 HOT 1
- Fix the wrong doc caused by monkey patch HOT 1
- The print statements cause the fails in doctest in Python 3 HOT 3
- The test of SQLite should be split into doctest and example HOT 1
- 支援一些特殊語法 HOT 4
- Add doc for subquery and the `AS` feature. HOT 1
- AS does not work in JOIN HOT 1
- "Unloading" MySQL fixes HOT 1
- Multi-row INSERT HOT 6
- mosql.sqlite leaks docs
- mosql.func leaks docs HOT 1
- benchmark script HOT 1
- Coercing values during chaining HOT 1
- BigQuery support HOT 1
- Migrate the Tests to Nose HOT 5
- 0.9.1 does not work on Python 3 HOT 1
- SQLite patch should stringify True and False to 1 and 0
- Expand ConnContext and make it as a new feature HOT 1
- Subquery support and `raw` objects HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mosql.