Skip to content
This repository has been archived by the owner on Aug 7, 2020. It is now read-only.

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Mar 12, 2020
1 parent 086c560 commit 594015d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
30 changes: 14 additions & 16 deletions docs/using/intro.md
Expand Up @@ -185,9 +185,9 @@ All tokens have a `children` attribute:

```python
>> doc.children
[Paragraph(children=2, position=(2, 2)),
List(children=1, loose=False, start_at=1, position=(3, 4)),
Quote(children=1, position=(6, 6))]
[Paragraph(children=2, position=Position(lines=[2:2])),
List(children=1, loose=False, start_at=1, position=Position(lines=[3:4])),
Quote(children=1, position=Position(lines=[6:6]))]
```

or you can walk through the entire syntax tree, using the
Expand All @@ -196,18 +196,18 @@ or you can walk through the entire syntax tree, using the
```python
>> for item in doc.walk():
.. print(item)
WalkItem(node=Paragraph(children=2, position=(2, 2)), parent=Document(children=3, link_definitions=0, footnotes=0, footref_order=0, front_matter=None), index=0, depth=1)
WalkItem(node=List(children=1, loose=False, start_at=1, position=(3, 4)), parent=Document(children=3, link_definitions=0, footnotes=0, footref_order=0, front_matter=None), index=1, depth=1)
WalkItem(node=Quote(children=1, position=(6, 6)), parent=Document(children=3, link_definitions=0, footnotes=0, footref_order=0, front_matter=None), index=2, depth=1)
WalkItem(node=RawText(), parent=Paragraph(children=2, position=(2, 2)), index=0, depth=2)
WalkItem(node=Emphasis(children=1), parent=Paragraph(children=2, position=(2, 2)), index=1, depth=2)
WalkItem(node=ListItem(children=1, loose=False, leader='1.', prepend=3, next_marker=None, position=(3, 4)), parent=List(children=1, loose=False, start_at=1, position=(3, 4)), index=0, depth=2)
WalkItem(node=Paragraph(children=2, position=(7, 7)), parent=Quote(children=1, position=(6, 6)), index=0, depth=2)
WalkItem(node=Paragraph(children=2, position=Position(lines=[2:2])), parent=Document(children=3, link_definitions=0, footnotes=0, footref_order=0, front_matter=None), index=0, depth=1)
WalkItem(node=List(children=1, loose=False, start_at=1, position=Position(lines=[3:4])), parent=Document(children=3, link_definitions=0, footnotes=0, footref_order=0, front_matter=None), index=1, depth=1)
WalkItem(node=Quote(children=1, position=Position(lines=[6:6])), parent=Document(children=3, link_definitions=0, footnotes=0, footref_order=0, front_matter=None), index=2, depth=1)
WalkItem(node=RawText(), parent=Paragraph(children=2, position=Position(lines=[2:2])), index=0, depth=2)
WalkItem(node=Emphasis(children=1), parent=Paragraph(children=2, position=Position(lines=[2:2])), index=1, depth=2)
WalkItem(node=ListItem(children=1, loose=False, leader='1.', prepend=3, next_marker=None, position=Position(lines=[3:4])), parent=List(children=1, loose=False, start_at=1, position=Position(lines=[3:4])), index=0, depth=2)
WalkItem(node=Paragraph(children=2, position=Position(lines=[7:7])), parent=Quote(children=1, position=Position(lines=[6:6])), index=0, depth=2)
WalkItem(node=RawText(), parent=Emphasis(children=1), index=0, depth=3)
WalkItem(node=Paragraph(children=1, position=(4, 4)), parent=ListItem(children=1, loose=False, leader='1.', prepend=3, next_marker=None, position=(3, 4)), index=0, depth=3)
WalkItem(node=RawText(), parent=Paragraph(children=2, position=(7, 7)), index=0, depth=3)
WalkItem(node=Emphasis(children=1), parent=Paragraph(children=2, position=(7, 7)), index=1, depth=3)
WalkItem(node=RawText(), parent=Paragraph(children=1, position=(4, 4)), index=0, depth=4)
WalkItem(node=Paragraph(children=1, position=Position(lines=[4:4])), parent=ListItem(children=1, loose=False, leader='1.', prepend=3, next_marker=None, position=Position(lines=[3:4])), index=0, depth=3)
WalkItem(node=RawText(), parent=Paragraph(children=2, position=Position(lines=[7:7])), index=0, depth=3)
WalkItem(node=Emphasis(children=1), parent=Paragraph(children=2, position=Position(lines=[7:7])), index=1, depth=3)
WalkItem(node=RawText(), parent=Paragraph(children=1, position=Position(lines=[4:4])), index=0, depth=4)
WalkItem(node=RawText(), parent=Emphasis(children=1), index=0, depth=4)
```

Expand All @@ -217,10 +217,8 @@ You could even build your own AST programatically!
>> from mistletoe import block_tokens, span_tokens, HTMLRenderer
>> doc = block_tokens.Document(children=[
.. block_tokens.Paragraph(
.. position=(0, 1),
.. children=[
.. span_tokens.Emphasis(
.. position=(0, 1),
.. children=[span_tokens.RawText("hallo")]
.. )
.. ])
Expand Down
8 changes: 4 additions & 4 deletions mistletoe/base_elements.py
Expand Up @@ -240,7 +240,7 @@ def backstep(self):


@autodoc
@attr.s(slots=True, kw_only=True)
@attr.s(slots=True, kw_only=True, repr=False)
class Position:
"""Dataclass to store positional data of tokens, in relation to the source text."""

Expand Down Expand Up @@ -268,13 +268,13 @@ def from_source_lines(cls, lines: SourceLines, start_line=None) -> "Position":

def __repr__(self):
args = ""
if self.line_end is None:
args += "lines=({0},{1})".format(self.line_start, self.line_end)
if self.line_end is not None:
args += "lines=[{0}:{1}]".format(self.line_start, self.line_end)
else:
args += "line={0}".format(self.line_start)
if self.uri is not None:
args += ",uri={0}".format(self.uri)
if self.data is not None:
if self.data:
args += ",data={0}".format(self.data)
return "{0}({1})".format(self.__class__.__name__, args)

Expand Down

0 comments on commit 594015d

Please sign in to comment.