def documentation(self): commands = [ "{}:\n{}".format( cmd.matcher.pattern, format_doc_text(cmd.doc or inspect.getdoc(cmd.func) or ""), ) for cmd in sorted( self.interface.bound_commands, key=lambda x: x.matcher.pattern ) ] options = format_doc_text( "Listening on: {}\nPort: {}\nRequest terminator: {}\nReply terminator: {}".format( self._options.bind_address, self._options.port, repr(self.interface.in_terminator), repr(self.interface.out_terminator), ) ) return "\n\n".join( [ inspect.getdoc(self.interface) or "", "Parameters\n==========", options, "Commands\n========", ] + commands )
def documentation(self): commands = ['{}:\n{}'.format( cmd.matcher.pattern, format_doc_text(cmd.doc or inspect.getdoc(cmd.func) or '')) for cmd in sorted(self.interface.bound_commands, key=lambda x: x.matcher.pattern)] options = format_doc_text( 'Listening on: {}\nPort: {}\nRequest terminator: {}\nReply terminator: {}'.format( self._options.bind_address, self._options.port, repr(self.interface.in_terminator), repr(self.interface.out_terminator))) return '\n\n'.join( [inspect.getdoc(self.interface) or '', 'Parameters\n==========', options, 'Commands\n========'] + commands)
def test_long_lines_are_broken(self): text = " ".join(["ab"] * 44) expected = ( " " + " ".join(["ab"] * 32) + "\n" + " " + " ".join(["ab"] * 12) ) self.assertEqual(format_doc_text(text), expected)
def documentation(self): commands = [ '{}:\n{}'.format( cmd.pattern.pattern, format_doc_text(cmd.doc or inspect.getdoc(getattr(self, cmd.method)) or '')) for cmd in self.commands ] options = format_doc_text( 'Listening on: {}\nPort: {}\nRequest terminator: {}\nReply terminator: {}' .format(self._options.bind_address, self._options.port, repr(self.in_terminator), repr(self.out_terminator))) return '\n\n'.join([ inspect.getdoc(self) or '', 'Parameters\n==========', options, 'Commands\n========' ] + commands)
def documentation(self): pvs = [] for name, pv in self.interface.bound_pvs.items(): complete_name = self._options.prefix + name data_type = pv.config.get('type', 'float') read_only_tag = ', read only' if pv.read_only else '' pvs.append('{} ({}{}):\n{}'.format( complete_name, data_type, read_only_tag, format_doc_text(pv.doc))) return '\n\n'.join( [inspect.getdoc(self.interface) or '', 'PVs\n==='] + pvs)
def documentation(self): pvs = [] for name, pv in self.interface.bound_pvs.items(): complete_name = self._options.prefix + name data_type = pv.config.get("type", "float") read_only_tag = ", read only" if pv.read_only else "" pvs.append("{} ({}{}):\n{}".format(complete_name, data_type, read_only_tag, format_doc_text(pv.doc))) return "\n\n".join([inspect.getdoc(self.interface) or "", "PVs\n==="] + pvs)
def documentation(self): pvs = [] for name, pv in self.interface.bound_pvs.items(): complete_name = self._options.prefix + name data_type = pv.config.get('type', 'float') read_only_tag = ', read only' if pv.read_only else '' pvs.append('{} ({}{}):\n{}'.format(complete_name, data_type, read_only_tag, format_doc_text(pv.doc))) return '\n\n'.join([inspect.getdoc(self.interface) or '', 'PVs\n==='] + pvs)
def test_no_lines_above_99(self): text = ' '.join(['abc'] * 143) converted = format_doc_text(text).split('\n') self.assertTrue(all([len(line) <= 99 for line in converted]))
def test_long_lines_are_broken(self): text = ' '.join(['ab'] * 44) expected = ' ' + ' '.join(['ab'] * 32) + '\n' + ' ' + ' '.join( ['ab'] * 12) self.assertEqual(format_doc_text(text), expected)
def test_indented_lines_are_cleaned_up(self): text = ' This is\n a test\n with multiple lines.' expected = ' This is\n a test\n with multiple lines.' self.assertEqual(format_doc_text(text), expected)
def test_lines_are_preserved_and_indented(self): text = 'This is\na test\nwith multiple lines.' expected = ' This is\n a test\n with multiple lines.' self.assertEqual(format_doc_text(text), expected)
def test_long_lines_are_broken(self): text = ' '.join(['ab'] * 44) expected = ' ' + ' '.join(['ab'] * 32) + '\n' + ' ' + ' '.join(['ab'] * 12) self.assertEqual(format_doc_text(text), expected)
def test_no_lines_above_99(self): text = " ".join(["abc"] * 143) converted = format_doc_text(text).split("\n") self.assertTrue(all([len(line) <= 99 for line in converted]))