| 8 | |
| 9 | |
| 10 | class CsharpParser(LanguageParser): |
| 11 | |
| 12 | BLACKLISTED_FUNCTION_NAMES = [] |
| 13 | |
| 14 | @staticmethod |
| 15 | def get_docstring(node, blob=None): |
| 16 | """ |
| 17 | Get docstring description for node |
| 18 | |
| 19 | Args: |
| 20 | node (tree_sitter.Node) |
| 21 | blob (str): original source code which parse the `node` |
| 22 | Returns: |
| 23 | str: docstring |
| 24 | """ |
| 25 | if blob: |
| 26 | logger.info('From version `0.0.6` this function will update argument in the API') |
| 27 | docstring_node = CsharpParser.get_docstring_node(node) |
| 28 | docstring = '\n'.join(get_node_text(s) for s in docstring_node) |
| 29 | return docstring |
| 30 | |
| 31 | @staticmethod |
| 32 | def get_docstring_node(node): |
| 33 | """ |
| 34 | Get docstring node from it parent node. |
| 35 | C# docstring is written line by line and stay outside it own node, see example below. |
| 36 | |
| 37 | Args: |
| 38 | node (tree_sitter.Node): parent node (usually function node) to get its docstring |
| 39 | Return: |
| 40 | List: list of docstring nodes |
| 41 | Example: |
| 42 | str = ''' |
| 43 | // <summary> |
| 44 | // Docstring of a method |
| 45 | // </summary> |
| 46 | // <param name="animal_honk">Argument.</param> |
| 47 | // <returns> |
| 48 | // None. |
| 49 | public void honk(string animal_honk) |
| 50 | { |
| 51 | Console.WriteLine(animal_honk); |
| 52 | Console.WriteLine("Tuut, tuut!"); |
| 53 | } |
| 54 | ''' |
| 55 | ... |
| 56 | print(C_sharp.get_docstring_node(function_node)) |
| 57 | |
| 58 | >>> [<Node type=comment, start_point=(5, 12), end_point=(5, 24)>, \ |
| 59 | <Node type=comment, start_point=(6, 12), end_point=(6, 36)>, \ |
| 60 | <Node type=comment, start_point=(7, 12), end_point=(7, 25)>, \ |
| 61 | <Node type=comment, start_point=(8, 12), end_point=(8, 58)>, \ |
| 62 | <Node type=comment, start_point=(9, 12), end_point=(9, 24)>, \ |
| 63 | <Node type=comment, start_point=(10, 12), end_point=(10, 20)>] |
| 64 | """ |
| 65 | docstring_node = [] |
| 66 | |
| 67 | prev_node = node.prev_sibling |
nothing calls this directly
no outgoing calls
no test coverage detected