from sphinxcontrib import napoleon
from sphinxcontrib.napoleon._upstream import _
from sphinxcontrib.napoleon import GoogleDocstring


def _parse_inputs(self, section):
    return self._format_fields(_('Input Ports'), self._consume_fields())
GoogleDocstring._parse_inputs = _parse_inputs

def _parse_outputs(self, section):
    return self._format_fields(_('Output Ports'), self._consume_fields())
GoogleDocstring._parse_outputs = _parse_outputs

def _parse_state(self, section):
    return self._format_fields(_('State'), self._consume_fields())
GoogleDocstring._parse_state = _parse_state

def patched_parse(self):
    self._sections['input ports'] = self._parse_inputs
    self._sections['output ports'] = self._parse_outputs
    self._sections['state'] = self._parse_state
    self._unpatched_parse()
GoogleDocstring._unpatched_parse = GoogleDocstring._parse
GoogleDocstring._parse = patched_parse

setup = napoleon.setup