GithubHelp home page GithubHelp logo

rob-smallshire / cartouche Goto Github PK

View Code? Open in Web Editor NEW
5.0 5.0 3.0 223 KB

A Sphinx extension to convert help() friendly docstrings to Sphinx markup

License: BSD 3-Clause "New" or "Revised" License

Python 89.34% Makefile 5.36% Batchfile 5.30%

cartouche's People

Contributors

rob-smallshire avatar slode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cartouche's Issues

Parse errors do not report file or line number or line contents causing error.

Original author: [email protected] (October 05, 2012 16:47:07)

What steps will reproduce the problem?

  1. Write a comment that does not parse correctly, like leaving the colon (:) out of an Args specification.

What is the expected output? What do you see instead?

I expect cartouche to let me know what file / line number (maybe line contents) that parsed incorrectly. I could probably figure it out from there.

Instead it fails with this error:
"Invalid cartouche argument syntax"

There are a lot of files in the project, and lots of comments with Args lists, where do I start?

What version of the product are you using? On what operating system?

cartouche 0.9 from PyPI on CentOS 6 64 bit

Original issue: http://code.google.com/p/cartouche/issues/detail?id=9

broken in Python 2.X due to print not being a function

cartouche/nodes.py is invalid Python 2.X syntax because print is being used like a function instead of a statement which does not allow keyword args.

  File "/home/sgoss/projects/cartouche/cartouche/nodes.py", line 64
    print("Missing argument description for {name}".format(name=self.name), file=sys.stderr)
                                                                                ^
SyntaxError: invalid syntax

UnboundLocalError: local variable 'arg' referenced before assignment

Original author: [email protected] (June 29, 2012 07:01:08)

Imported from hieroglyph

The following docstring:

'''
Execute the command described by concatenating the string function arguments
with the p4 -s global scripting flag and return the results in a dictionary.

For example, to run the command::

  p4 -s fstat -T depotFile foo.h

call::

  p4('fstat', '-T', 'depotFile', 'foo.h')

Args:
    args: The arguments to the p4 command as a list of objects which will
        be converted to strings.

Returns:
    A dictionary of lists where each key in the dictionary is the field name
    from the command output, and each value is a list of output lines in
    order.

Raises:
    PerforceError: If the command could not be run or if the command
        reported an error.
'''

produced the error:

lines = [u'Execute the command described by concatenating the string function ar
guments', u'with the p4 -s global scripting flag and return the results in a dic
tionary.', u'', u'For example, to run the command,', u'', u' p4 -s fstat -T dep
otFile foo.h', u' ', u'call,', u'', u" p4('fstat', '-T', 'depotFile', 'foo.h')
", u'', u'Args:', u' *args: The arguments to the p4 command as a list of obje
cts which will', u' be converted to strings.', u' ', u'Returns:', u'
A dictionary of lists where each key in the dictionary is the field name', u'
from the command output, and each value is a list of output lines in', u'
order.', u' ', u'Raises:', u' PerforceError: If the command could not be r
un or if the command', u' reported an error.', u'']

Exception occurred:
File "c:\Python27\lib\site-packages\hieroglyph-0.5dev_20110318-py2.7.egg\hiero
glyph\hieroglyph.py", line 80, in convert_args
last_child = arg.children[-1] if len(arg.children) != 0 else arg
UnboundLocalError: local variable 'arg' referenced before assignment

Original issue: http://code.google.com/p/cartouche/issues/detail?id=4

Missing argument name causes failure

Original author: [email protected] (June 29, 2012 06:59:40)

Issue imported from hieroglyph

Running Sphinx v1.0.7
loading pickled environment... not yet created
building [html]: targets for 6 source files that are out of date
updating environment: 6 added, 0 changed, 0 removed
reading sources... [ 16%] api/canoncial
lines = [u'Parse a single line of a tree to determine depth and node.', u'', u'A
rgs:', u' A single line string from a SCons dependency tree.', u' ', u'Ret
urns:', u' A 2-tuple containing the tree 0 based tree depth as the first', u'
element and the node description as the second element.', u'', u'Raises:', u
' ValueError: If line does not have the expected form.', u'']

Exception occurred:
File "c:\Python27\lib\site-packages\hieroglyph-0.5dev_20110318-py2.7.egg\hiero
glyph\hieroglyph.py", line 80, in convert_args
last_child = arg.children[-1] if len(arg.children) != 0 else arg
UnboundLocalError: local variable 'arg' referenced before assignment
The full traceback has been saved in c:\users\robert~1.emr\appdata\local\temp\sp
hinx-err-2ngbwq.log, if you want to report the issue to the developers.

In this case the fourth element contains u' A single line string from a SCons dependency tree.' whereas it should contain u' line: A single line string from a SCons dependency tree.'

Hieroglyph should detect this and report a sensible error message.

Original issue: http://code.google.com/p/cartouche/issues/detail?id=3

setup.py imports code that tries to load sphinx

Original author: [email protected] (October 05, 2012 18:28:36)

What steps will reproduce the problem?

  1. pip install cartouche or in source folder python setup.py install before sphinx is installed

What is the expected output? What do you see instead?

I expect the sphinx requirement to be resolved automatically, instead it just explodes because setup.py tries to import sphinx when it is importing the version number from the code.

Please provide any additional information below.

This line is the problem:

from cartouche import __version__ as version

You can't do that. if you replace it with this line:

version = 0.9

it works! it gives pip a chance to resolve the sphinx requirement automatically.

Original issue: http://code.google.com/p/cartouche/issues/detail?id=10

Args with explicit modules and dots in type specifier do not parse

Original author: [email protected] (October 05, 2012 16:34:40)

What steps will reproduce the problem?

  1. Create an args list like this:
    Args:
    foo (foo_module.SomeClass): something something
  2. Let cartouche loose on the code

What is the expected output? What do you see instead?

It is expected that cartouche could parse the "foo_module.SomeClass" bit, since you know, there might be a bar_module.SomeClass also in play, we want to specify which one we are using.

Instead, cartouche spits out this error without any hint of what file or line might be causing the problem: "Invalid cartouche argument syntax"

What version of the product are you using? On what operating system?

cartouche 0.9 from PyPI, CentOS 6 64 bit

Please provide any additional information below.

it's obvious that this regex is insufficient:

ARG_REGEX = re.compile(r'({0,2}\w+)(\s+((\w+)))?\s_:\s_(.)')

trying to match the class specifier with \w+

Original issue: http://code.google.com/p/cartouche/issues/detail?id=8

cartouche not parsing multi-line exception syntax

Original author: [email protected] (October 17, 2012 19:47:13)

What steps will reproduce the problem?

  1. Include the following as the docstring for a method:
    """
    Raises:
    Exception: This is a multi-line
    bug.
    """
  2. Try to build the documentation with sphinx-build

What is the expected output? What do you see instead?

Expected:
build without errors.

Actual:
Extension error:
Invalid cartouche exception syntax

What version of the product are you using? On what operating system?

Sphinx v1.1.3
cartouche v0.9
CentOS release 6.3 (Final)

Please provide any additional information below.

n/a

Original issue: http://code.google.com/p/cartouche/issues/detail?id=11

nosetests explodes on setup function

I think nose runs the setup function in sphinxext.py erroneously (mistaking it as a test setup function), causing it to explode before any actual tests are run:

$ nosetests cartouche.test
E
======================================================================
ERROR: test suite for <module 'cartouche.test' from '/home/sgoss/projects/cartouche/cartouche/test/__init__.pyc'>
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/sgoss/projects/cartouche_env/local/lib/python2.7/site-packages/nose/suite.py", line 208, in run
    self.setUp()
  File "/home/sgoss/projects/cartouche_env/local/lib/python2.7/site-packages/nose/suite.py", line 291, in setUp
    self.setupContext(ancestor)
  File "/home/sgoss/projects/cartouche_env/local/lib/python2.7/site-packages/nose/suite.py", line 314, in setupContext
    try_run(context, names)
  File "/home/sgoss/projects/cartouche_env/local/lib/python2.7/site-packages/nose/util.py", line 476, in try_run
    return func(obj)
  File "/home/sgoss/projects/cartouche/cartouche/sphinxext.py", line 6, in setup
    app.add_config_value('cartouche_accept_bulleted_args', False, 'env')
AttributeError: 'module' object has no attribute 'add_config_value'

----------------------------------------------------------------------
Ran 0 tests in 0.000s

FAILED (errors=1)

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.