# eric7.QScintilla.DocstringGenerator.BaseDocstringGenerator

Module implementing a docstring generator base class.

### Global Attributes

None

### Classes

BaseDocstringGenerator | Class implementing a docstring generator base class.
DocstringMenuForEnterOnly | Class implementing a special menu reacting to the enter/return keys only.
FunctionInfo | Class implementing an object to store function information.

### Functions

getIndentStr | Function to get the indentation of a text.

## BaseDocstringGenerator

Class implementing a docstring generator base class.

### Derived from

None

### Class Attributes

None

### Class Methods

None

### Methods

BaseDocstringGenerator | Constructor
_generateDocstringList | Protected method to generate type specific docstrings based on the extracted function information.
getDocstringType | Public method to determine the docstring type to be generated.
hasFunctionDefinition | Public method to test, if the cursor is right below a function definition.
insertDocstring | Public method to insert a docstring for the function at the cursor position.
insertDocstringFromShortcut | Public method to insert a docstring for the function at the cursor position initiated via a keyboard shortcut.
isDocstringIntro | Public function to test, if the line up to the cursor position might be introducing a docstring.
isFunctionStart | Public method to test, if a text is the start of a function or method definition.

### Static Methods

None

#### BaseDocstringGenerator (Constructor)

BaseDocstringGenerator(editor)

Constructor

editor (Editor)
  reference to the editor widget

#### BaseDocstringGenerator._generateDocstringList

_generateDocstringList(functionInfo, docstringType)

Protected method to generate type specific docstrings based on the extracted function information.

functionInfo (FunctionInfo)
  reference to the function info object
docstringType
  kind of docstring to be generated

Return:
  list of docstring lines

Return Type:
  str

#### BaseDocstringGenerator.getDocstringType

getDocstringType()

Public method to determine the docstring type to be generated.

Return:
  docstring type (one of 'ericdoc', 'numpydoc', 'googledoc', 'sphinxdoc')

Return Type:
  str

#### BaseDocstringGenerator.hasFunctionDefinition

hasFunctionDefinition(cursorPosition)

Public method to test, if the cursor is right below a function definition.

cursorPosition (tuple of (int, int))
  current cursor position (line and column)

Return:
  flag indicating cursor is right below a function definition

Return Type:
  bool

#### BaseDocstringGenerator.insertDocstring

insertDocstring(cursorPosition, fromStart=True)

Public method to insert a docstring for the function at the cursor position.

cursorPosition (tuple of (int, int))
  position of the cursor (line and index)
fromStart (bool)
  flag indicating that the editor text cursor is placed on the line starting the function definition

#### BaseDocstringGenerator.insertDocstringFromShortcut

insertDocstringFromShortcut(cursorPosition)

Public method to insert a docstring for the function at the cursor position initiated via a keyboard shortcut.

cursorPosition (tuple of (int, int))
  position of the cursor (line and index)

#### BaseDocstringGenerator.isDocstringIntro

isDocstringIntro(cursorPosition)

Public function to test, if the line up to the cursor position might be introducing a docstring.

cursorPosition (tuple of (int, int))
  current cursor position (line and column)

Return:
  flag indicating a potential start of a docstring

Return Type:
  bool

#### BaseDocstringGenerator.isFunctionStart

isFunctionStart(text)

Public method to test, if a text is the start of a function or method definition.

text (str)
  line of text to be tested

Return:
  flag indicating that the given text starts a function or method definition (always False)

Return Type:
  bool

Up

## DocstringMenuForEnterOnly

Class implementing a special menu reacting to the enter/return keys only.

If a keyboard input is not the "enter key", the menu is closed and the input is inserted to the code editor.

### Derived from

QMenu

### Class Attributes

None

### Class Methods

None

### Methods

DocstringMenuForEnterOnly | Constructor
keyPressEvent | Protected method to handle key press events.

### Static Methods

None

#### DocstringMenuForEnterOnly (Constructor)

DocstringMenuForEnterOnly(editor)

Constructor

editor (Editor)
  reference to the editor

#### DocstringMenuForEnterOnly.keyPressEvent

keyPressEvent(evt)

Protected method to handle key press events.

evt (QKeyEvent)
  reference to the key press event object

Up

## FunctionInfo

Class implementing an object to store function information.

Methods to extract the relevant information need to be implemented in language specific subclasses.

### Derived from

None

### Class Attributes

None

### Class Methods

None

### Methods

FunctionInfo | Constructor

### Static Methods

None

#### FunctionInfo (Constructor)

FunctionInfo()

Constructor

Up

## getIndentStr

getIndentStr(text)

Function to get the indentation of a text.

text (str)
  text to extract indentation from

Return:
  indentation string

Return Type:
  str

Up