comparison doc/hgmanpage.py @ 29158:7c0297bfe8bf

py3: make raise statement python3 compatible In python3 raise error, message has been changed to raise error(message) In additional to that nodes.SkipNode is changed to nodes.SkipNode() so that it creates an instance directly.
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 13 May 2016 03:18:04 +0530
parents cd5e7195e441
children ead25aa27a43
comparison
equal deleted inserted replaced
29153:90d84e1e427a 29158:7c0297bfe8bf
413 if name == 'author': 413 if name == 'author':
414 self._docinfo[name].append(node.astext()) 414 self._docinfo[name].append(node.astext())
415 else: 415 else:
416 self._docinfo[name] = node.astext() 416 self._docinfo[name] = node.astext()
417 self._docinfo_keys.append(name) 417 self._docinfo_keys.append(name)
418 raise nodes.SkipNode 418 raise nodes.SkipNode()
419 419
420 def depart_docinfo_item(self, node): 420 def depart_docinfo_item(self, node):
421 pass 421 pass
422 422
423 def visit_author(self, node): 423 def visit_author(self, node):
467 def depart_citation(self, node): 467 def depart_citation(self, node):
468 pass 468 pass
469 469
470 def visit_citation_reference(self, node): 470 def visit_citation_reference(self, node):
471 self.body.append('['+node.astext()+']') 471 self.body.append('['+node.astext()+']')
472 raise nodes.SkipNode 472 raise nodes.SkipNode()
473 473
474 def visit_classifier(self, node): 474 def visit_classifier(self, node):
475 pass 475 pass
476 476
477 def depart_classifier(self, node): 477 def depart_classifier(self, node):
487 self.body.append("%s.\n" % ('L '*len(self.colspecs))) 487 self.body.append("%s.\n" % ('L '*len(self.colspecs)))
488 488
489 def visit_comment(self, node, 489 def visit_comment(self, node,
490 sub=re.compile('-(?=-)').sub): 490 sub=re.compile('-(?=-)').sub):
491 self.body.append(self.comment(node.astext())) 491 self.body.append(self.comment(node.astext()))
492 raise nodes.SkipNode 492 raise nodes.SkipNode()
493 493
494 def visit_contact(self, node): 494 def visit_contact(self, node):
495 self.visit_docinfo_item(node, 'contact') 495 self.visit_docinfo_item(node, 'contact')
496 496
497 depart_contact = depart_docinfo_item 497 depart_contact = depart_docinfo_item
641 def visit_field_body(self, node): 641 def visit_field_body(self, node):
642 if self._in_docinfo: 642 if self._in_docinfo:
643 name_normalized = self._field_name.lower().replace(" ","_") 643 name_normalized = self._field_name.lower().replace(" ","_")
644 self._docinfo_names[name_normalized] = self._field_name 644 self._docinfo_names[name_normalized] = self._field_name
645 self.visit_docinfo_item(node, name_normalized) 645 self.visit_docinfo_item(node, name_normalized)
646 raise nodes.SkipNode 646 raise nodes.SkipNode()
647 647
648 def depart_field_body(self, node): 648 def depart_field_body(self, node):
649 pass 649 pass
650 650
651 def visit_field_list(self, node): 651 def visit_field_list(self, node):
655 self.dedent() 655 self.dedent()
656 656
657 def visit_field_name(self, node): 657 def visit_field_name(self, node):
658 if self._in_docinfo: 658 if self._in_docinfo:
659 self._field_name = node.astext() 659 self._field_name = node.astext()
660 raise nodes.SkipNode 660 raise nodes.SkipNode()
661 else: 661 else:
662 self.body.append(self.defs['field_name'][0]) 662 self.body.append(self.defs['field_name'][0])
663 663
664 def depart_field_name(self, node): 664 def depart_field_name(self, node):
665 self.body.append(self.defs['field_name'][1]) 665 self.body.append(self.defs['field_name'][1])
691 self.document.reporter.warning('"footnote_backrefs" not supported', 691 self.document.reporter.warning('"footnote_backrefs" not supported',
692 base_node=node) 692 base_node=node)
693 693
694 def visit_footnote_reference(self, node): 694 def visit_footnote_reference(self, node):
695 self.body.append('['+self.deunicode(node.astext())+']') 695 self.body.append('['+self.deunicode(node.astext())+']')
696 raise nodes.SkipNode 696 raise nodes.SkipNode()
697 697
698 def depart_footnote_reference(self, node): 698 def depart_footnote_reference(self, node):
699 pass 699 pass
700 700
701 def visit_generated(self, node): 701 def visit_generated(self, node):
703 703
704 def depart_generated(self, node): 704 def depart_generated(self, node):
705 pass 705 pass
706 706
707 def visit_header(self, node): 707 def visit_header(self, node):
708 raise NotImplementedError, node.astext() 708 raise NotImplementedError(node.astext())
709 709
710 def depart_header(self, node): 710 def depart_header(self, node):
711 pass 711 pass
712 712
713 def visit_hint(self, node): 713 def visit_hint(self, node):
740 if 'alt' in node.attributes: 740 if 'alt' in node.attributes:
741 text.append(node.attributes['alt']) 741 text.append(node.attributes['alt'])
742 if 'uri' in node.attributes: 742 if 'uri' in node.attributes:
743 text.append(node.attributes['uri']) 743 text.append(node.attributes['uri'])
744 self.body.append('[image: %s]\n' % ('/'.join(text))) 744 self.body.append('[image: %s]\n' % ('/'.join(text)))
745 raise nodes.SkipNode 745 raise nodes.SkipNode()
746 746
747 def visit_important(self, node): 747 def visit_important(self, node):
748 self.visit_admonition(node, 'important') 748 self.visit_admonition(node, 'important')
749 749
750 depart_important = depart_admonition 750 depart_important = depart_admonition
751 751
752 def visit_label(self, node): 752 def visit_label(self, node):
753 # footnote and citation 753 # footnote and citation
754 if (isinstance(node.parent, nodes.footnote) 754 if (isinstance(node.parent, nodes.footnote)
755 or isinstance(node.parent, nodes.citation)): 755 or isinstance(node.parent, nodes.citation)):
756 raise nodes.SkipNode 756 raise nodes.SkipNode()
757 self.document.reporter.warning('"unsupported "label"', 757 self.document.reporter.warning('"unsupported "label"',
758 base_node=node) 758 base_node=node)
759 self.body.append('[') 759 self.body.append('[')
760 760
761 def depart_label(self, node): 761 def depart_label(self, node):
812 def depart_literal_block(self, node): 812 def depart_literal_block(self, node):
813 self._in_literal = False 813 self._in_literal = False
814 self.body.append(self.defs['literal_block'][1]) 814 self.body.append(self.defs['literal_block'][1])
815 815
816 def visit_meta(self, node): 816 def visit_meta(self, node):
817 raise NotImplementedError, node.astext() 817 raise NotImplementedError(node.astext())
818 818
819 def depart_meta(self, node): 819 def depart_meta(self, node):
820 pass 820 pass
821 821
822 def visit_note(self, node): 822 def visit_note(self, node):
922 922
923 def visit_raw(self, node): 923 def visit_raw(self, node):
924 if node.get('format') == 'manpage': 924 if node.get('format') == 'manpage':
925 self.body.append(node.astext() + "\n") 925 self.body.append(node.astext() + "\n")
926 # Keep non-manpage raw text out of output: 926 # Keep non-manpage raw text out of output:
927 raise nodes.SkipNode 927 raise nodes.SkipNode()
928 928
929 def visit_reference(self, node): 929 def visit_reference(self, node):
930 """E.g. link or email address.""" 930 """E.g. link or email address."""
931 self.body.append(self.defs['reference'][0]) 931 self.body.append(self.defs['reference'][0])
932 932
961 def depart_strong(self, node): 961 def depart_strong(self, node):
962 self.body.append(self.defs['strong'][1]) 962 self.body.append(self.defs['strong'][1])
963 963
964 def visit_substitution_definition(self, node): 964 def visit_substitution_definition(self, node):
965 """Internal only.""" 965 """Internal only."""
966 raise nodes.SkipNode 966 raise nodes.SkipNode()
967 967
968 def visit_substitution_reference(self, node): 968 def visit_substitution_reference(self, node):
969 self.document.reporter.warning('"substitution_reference" not supported', 969 self.document.reporter.warning('"substitution_reference" not supported',
970 base_node=node) 970 base_node=node)
971 971
1007 self.body.extend(self._active_table.as_list()) 1007 self.body.extend(self._active_table.as_list())
1008 self._active_table = None 1008 self._active_table = None
1009 1009
1010 def visit_target(self, node): 1010 def visit_target(self, node):
1011 # targets are in-document hyper targets, without any use for man-pages. 1011 # targets are in-document hyper targets, without any use for man-pages.
1012 raise nodes.SkipNode 1012 raise nodes.SkipNode()
1013 1013
1014 def visit_tbody(self, node): 1014 def visit_tbody(self, node):
1015 pass 1015 pass
1016 1016
1017 def depart_tbody(self, node): 1017 def depart_tbody(self, node):
1051 self.body.append('.IP "') 1051 self.body.append('.IP "')
1052 elif self.section_level == 0: 1052 elif self.section_level == 0:
1053 self._docinfo['title'] = node.astext() 1053 self._docinfo['title'] = node.astext()
1054 # document title for .TH 1054 # document title for .TH
1055 self._docinfo['title_upper'] = node.astext().upper() 1055 self._docinfo['title_upper'] = node.astext().upper()
1056 raise nodes.SkipNode 1056 raise nodes.SkipNode()
1057 elif self.section_level == 1: 1057 elif self.section_level == 1:
1058 self.body.append('.SH ') 1058 self.body.append('.SH ')
1059 for n in node.traverse(nodes.Text): 1059 for n in node.traverse(nodes.Text):
1060 n.parent.replace(n, nodes.Text(n.astext().upper())) 1060 n.parent.replace(n, nodes.Text(n.astext().upper()))
1061 else: 1061 else: