def test_doc_paragraph_zero_indent(self): string = doc_paragraph('The quick brown fox jumped over the yellow ' 'doge. The quick brown fox jumped over.', indent=0) if (string != 'The quick brown fox jumped over the yellow doge. ' 'The quick brown fox jumped\nover.'): raise AssertionError('incorrect string "{0}"'.format(string))
def decorator(func): out_name_end_index = func.__name__.find('_from_') if out_name_end_index == -1: raise ValueError('equation_docstring decorator must be applied to ' 'function whose name contains "_from_"') out_quantity = func.__name__[:out_name_end_index] in_quantities = inspect.getargspec(func).args docstring = 'Calculates {0}'.format( quantity_string(out_quantity, quantity_dict)) try: if len(func.assumptions) > 0: docstring += ' assuming {0}'.format( assumption_list_string(func.assumptions, assumption_dict)) except AttributeError: pass docstring += '.' docstring = doc_paragraph(docstring) docstring += '\n\n' if equation is not None: func.equation = equation docstring += doc_paragraph(':math:`' + equation.strip() + '`') docstring += '\n\n' docstring += 'Parameters\n' docstring += '----------\n\n' docstring += '\n'.join([quantity_spec_string(q, quantity_dict) for q in in_quantities]) docstring += '\n\n' docstring += 'Returns\n' docstring += '-------\n\n' docstring += quantity_spec_string(out_quantity, quantity_dict) if notes is not None: docstring += '\n\n' docstring += 'Notes\n' docstring += '-----\n\n' docstring += notes.strip() if references is not None: if notes is None: # still need notes header for references docstring += '\n\n' docstring += 'Notes\n' docstring += '-----\n\n' func.references = references docstring += '\n\n' docstring += '**References**\n\n' docstring += references.strip() docstring += '\n' func.__doc__ = docstring return func
def test_doc_paragraph_no_wrap_for_short_string(self): string = doc_paragraph('The quick brown fox jumped over the yellow ' 'doge. The quick brown fox jumped over') assert '\n' not in string