Last active
August 29, 2015 14:19
-
-
Save jaidevd/9b80e116d5b8a56f6a5a to your computer and use it in GitHub Desktop.
View Python docstrings through $EDITOR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# vim:fenc=utf-8 | |
# | |
# Copyright © 2015 jaidev <jaidev@newton> | |
# | |
# Distributed under terms of the MIT license. | |
""" | |
""" | |
import sys | |
import tempfile | |
def main(funcpath): | |
namespace = funcpath.split('.') | |
base = namespace[-1] | |
expression = "from {0} import {1}".format(".".join(namespace[:-1]), base) | |
exec(expression) | |
docstring = eval("{}.__doc__".format(base)) | |
with tempfile.NamedTemporaryFile(delete=False) as f: | |
f.write(docstring) | |
print f.name | |
if __name__ == '__main__': | |
main(sys.argv[1]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# pyds | |
function pyds { | |
DOCPATH=`python ~/src/pyds/pyds.py $1` | |
$EDITOR $DOCPATH | |
rm $DOCPATH | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment