# Empty docstring

==>

Docstring

# Keyword lines

Key
  foo
Headline
  a function

==>

Docstring(
  Section(Keyword, Program(Identifier)),
  Section(Keyword, Verbatim))

# Nested sections

Node
  Key
    foo
  Description
    Text
      Some text.
    Example
      R = QQ[x]
      x^2

==>

Docstring(Section(Keyword,
  Section(Keyword, Program(Identifier)),
  Section(Keyword,
    Section(Keyword, Prose),
    Section(Keyword, Program(
      BinaryExpr(Definition, AssignmentOp, Application(BuiltinType, Array("[", Identifier, "]"))),
      BinaryExpr(Identifier, ArithmeticOp, Integer))))))

# Empty sections

Key
Headline
  a function

==>

Docstring(
  Section(Keyword),
  Section(Keyword, Verbatim))

# A keyword is a whole line

Headline blah
  a function

==>

Docstring(Section(⚠, Prose))

# Keywords are not keywords inside bodies

Code
  Text
Text
  Example

==>

Docstring(
  Section(Keyword, Program(BuiltinConstant)),
  Section(Keyword, Prose))

# A shallower keyword pulls the floor down

Description
    Text
      a
  Text
    b
    Text
      c

==>

Docstring(Section(Keyword,
  Section(Keyword, Prose),
  Section(Keyword, Prose)))

# Tabs advance to the next multiple of 8

Description
	Text
	  a
        Text
          b
 	Text
     	 c

==>

Docstring(Section(Keyword,
  Section(Keyword, Prose),
  Section(Keyword, Prose),
  Section(Keyword, Prose)))

# Comment lines never end a body

Example
  x = 1
-- a comment
  x + 1

==>

Docstring(Section(Keyword, Program(
  BinaryExpr(Definition, AssignmentOp, Integer),
  LineComment,
  BinaryExpr(Identifier, ArithmeticOp, Integer))))

# Trailing comment lines are outside the section

Pre
  a
  -- a comment

Text
  b

==>

Docstring(
  Section(Keyword, Verbatim),
  CommentLine,
  Section(Keyword, Prose))
