Package docutils :: Module statemachine :: Class StateWS
[show private | hide private]
[frames | no frames]

Class StateWS

State --+
        |
       StateWS

Known Subclasses:
RSTState

State superclass specialized for whitespace (blank lines & indents).

Use this class with StateMachineWS. The transitions 'blank' (for blank lines) and 'indent' (for indented text blocks) are added automatically, before any other transitions. The transition method blank() handles blank lines and indent() handles nested indented blocks. Indented blocks trigger a new state machine to be created by indent() and run. The class of the state machine to be created is in indent_sm, and the constructor keyword arguments are in the dictionary indent_sm_kwargs.

The methods known_indent() and firstknown_indent() are provided for indented blocks where the indent (all lines' and first line's only, respectively) is known to the transition method, along with the attributes known_indent_sm and known_indent_sm_kwargs. Neither transition method is triggered automatically.


Method Summary
  __init__(self, state_machine, debug)
Initialize a StateSM object; extends State.__init__().
  add_initial_transitions(self)
Add whitespace-specific transitions before those defined in subclass.
  blank(self, match, context, next_state)
Handle blank lines.
  first_known_indent(self, match, context, next_state)
Handle an indented text block (first line's indent known).
  indent(self, match, context, next_state)
Handle an indented text block.
  known_indent(self, match, context, next_state)
Handle a known-indent text block.
    Inherited from State
  add_transition(self, name, transition)
Add a transition to the start of the transition list.
  add_transitions(self, names, transitions)
Add a list of transitions to the start of the transition list.
  bof(self, context)
Handle beginning-of-file.
  eof(self, context)
Handle end-of-file.
  make_transition(self, name, next_state)
Make & return a transition tuple based on name.
  make_transitions(self, name_list)
Return a list of transition names and a transition mapping.
  no_match(self, context, transitions)
Called when there is no match from StateMachine.check_line().
  nop(self, match, context, next_state)
A "do nothing" transition method.
  remove_transition(self, name)
Remove a transition by name.
  runtime_init(self)
Initialize this State before running the state machine; called from self.state_machine.run().
  unlink(self)
Remove circular references to objects no longer required.

Class Variable Summary
NoneType indent_sm = None                                                                  
NoneType indent_sm_kwargs = None                                                                  
NoneType known_indent_sm = None                                                                  
NoneType known_indent_sm_kwargs = None                                                                  
tuple ws_initial_transitions = ('blank', 'indent')
dict ws_patterns = {'indent': ' +', 'blank': ' *$'}
    Inherited from State
NoneType initial_transitions = None                                                                  
NoneType nested_sm = None                                                                  
NoneType nested_sm_kwargs = None                                                                  
NoneType patterns = None                                                                  

Method Details

__init__(self, state_machine, debug=0)
(Constructor)

Initialize a StateSM object; extends State.__init__().

Check for indent state machine attributes, set defaults if not set.

Overrides:
docutils.statemachine.State.__init__

add_initial_transitions(self)

Add whitespace-specific transitions before those defined in subclass.

Extends State.add_initial_transitions().

Overrides:
docutils.statemachine.State.add_initial_transitions

blank(self, match, context, next_state)

Handle blank lines. Does nothing. Override in subclasses.

first_known_indent(self, match, context, next_state)

Handle an indented text block (first line's indent known).

Extend or override in subclasses.

Recursively run the registered state machine for known-indent indented blocks (self.known_indent_sm). The indent is the length of the match, match.end().

indent(self, match, context, next_state)

Handle an indented text block. Extend or override in subclasses.

Recursively run the registered state machine for indented blocks (self.indent_sm).

known_indent(self, match, context, next_state)

Handle a known-indent text block. Extend or override in subclasses.

Recursively run the registered state machine for known-indent indented blocks (self.known_indent_sm). The indent is the length of the match, match.end().


Class Variable Details

indent_sm

Type:
NoneType
Value:
None                                                                  

indent_sm_kwargs

Type:
NoneType
Value:
None                                                                  

known_indent_sm

Type:
NoneType
Value:
None                                                                  

known_indent_sm_kwargs

Type:
NoneType
Value:
None                                                                  

ws_initial_transitions

Type:
tuple
Value:
('blank', 'indent')                                                    

ws_patterns

Type:
dict
Value:
{'indent': ' +', 'blank': ' *$'}                                       

Generated by Epydoc 2.0 on Tue Jul 22 05:31:40 2003 http://epydoc.sf.net