from tangled.web import Resource, represent

from tangled.site.resources.entry import Entry


class Docs(Entry):

    @represent('text/html', template_name='tangled.website:templates/docs.mako')
    def GET(self):
        static_dirs = self.app.get_all('static_directory', as_dict=True)
        links = []
        for prefix, dir_app in static_dirs.items():
            if prefix[0] == 'docs':
                links.append({
                    'href': '/'.join(prefix),
                    'text': prefix[1],
                })
        self.urlvars['id'] = 'docs'
        data = super().GET()
        data['links'] = sorted(links, key=lambda i: i['text'])
        return data

from tangled.web import Resource, config

from tangled.site.resources.entry import Entry


class Docs(Entry):

    @config('text/html', template_name='tangled.website:templates/docs.mako')
    def GET(self):
        static_dirs = self.app.get_all('static_directory', as_dict=True)
        links = []
        for prefix, dir_app in static_dirs.items():
            if prefix[0] == 'docs':
                links.append({
                    'href': '/'.join(prefix),
                    'text': prefix[1],
                })
        self.urlvars['id'] = 'docs'
        data = super().GET()
        data['links'] = sorted(links, key=lambda i: i['text'])
        return data

Replace @represent w/ @config throughout
Replace @represent w/ @config throughout

New name, same functionality.

- from tangled.web import Resource, represent
+ from tangled.web import Resource, config
  
  from tangled.site.resources.entry import Entry
  
  
  class Docs(Entry):
  
-     @represent('text/html', template_name='tangled.website:templates/docs.mako')
+     @config('text/html', template_name='tangled.website:templates/docs.mako')
      def GET(self):
          static_dirs = self.app.get_all('static_directory', as_dict=True)
          links = []
          for prefix, dir_app in static_dirs.items():
              if prefix[0] == 'docs':
                  links.append({
                      'href': '/'.join(prefix),
                      'text': prefix[1],
                  })
          self.urlvars['id'] = 'docs'
          data = super().GET()
          data['links'] = sorted(links, key=lambda i: i['text'])
          return data
  
Replace @represent w/ @config throughout
## Code Before:
from tangled.web import Resource, represent

from tangled.site.resources.entry import Entry


class Docs(Entry):

    @represent('text/html', template_name='tangled.website:templates/docs.mako')
    def GET(self):
        static_dirs = self.app.get_all('static_directory', as_dict=True)
        links = []
        for prefix, dir_app in static_dirs.items():
            if prefix[0] == 'docs':
                links.append({
                    'href': '/'.join(prefix),
                    'text': prefix[1],
                })
        self.urlvars['id'] = 'docs'
        data = super().GET()
        data['links'] = sorted(links, key=lambda i: i['text'])
        return data

## Instruction:
Replace @represent w/ @config throughout
## Code After:
from tangled.web import Resource, config

from tangled.site.resources.entry import Entry


class Docs(Entry):

    @config('text/html', template_name='tangled.website:templates/docs.mako')
    def GET(self):
        static_dirs = self.app.get_all('static_directory', as_dict=True)
        links = []
        for prefix, dir_app in static_dirs.items():
            if prefix[0] == 'docs':
                links.append({
                    'href': '/'.join(prefix),
                    'text': prefix[1],
                })
        self.urlvars['id'] = 'docs'
        data = super().GET()
        data['links'] = sorted(links, key=lambda i: i['text'])
        return data
