<s> from harpoon . task_finder import TaskFinder <EOL> from harpoon . collector import Collector <EOL> from docutils . statemachine import ViewList <EOL> from sphinx . util . compat import Directive <EOL> from textwrap import dedent <EOL> from docutils import nodes <EOL> class ShowTasksDirective ( Directive ) : <EOL> """<STR_LIT>""" <EOL> has_content = True <EOL> def run ( self ) : <EOL> """<STR_LIT>""" <EOL> tokens = [ ] <EOL> section = nodes . section ( ) <EOL> section [ '<STR_LIT>' ] . append ( "<STR_LIT>" ) <EOL> title = nodes . title ( ) <EOL> title += nodes . Text ( "<STR_LIT>" ) <EOL> section += title <EOL> task_finder = TaskFinder ( Collector ( ) ) <EOL> for name , task in sorted ( task_finder . default_tasks ( ) . items ( ) , key = lambda x : len ( x [ <NUM_LIT:0> ] ) ) : <EOL> lines = [ name ] + [ "<STR_LIT>" . format ( line . strip ( ) ) for line in task . description . split ( '<STR_LIT:\n>' ) ] <EOL> viewlist = ViewList ( ) <EOL> for line in lines : <EOL> viewlist . append ( line , name ) <EOL> self . state . nested_parse ( viewlist , self . content_offset , section ) <EOL> return [ section ] <EOL> def setup ( app ) : <EOL> """<STR_LIT>""" <EOL> app . add_directive ( '<STR_LIT>' , ShowTasksDirective ) </s>
