Skip to content
Snippets Groups Projects
Select Git revision
  • 886472d0f95b19b0c7e761f8abda2336bc7f93a5
  • master default protected
  • schneider/ir
  • rahix/user-space-ctx
  • schneider/iaq-python
  • schneider/ble-mini-demo
  • schneider/ble-ecg-stream-visu
  • schneider/mp-exception-print
  • schneider/sleep-display
  • schneider/deepsleep4
  • schneider/deepsleep2
  • schneider/deepsleep
  • schneider/ble-central
  • rahix/bluetooth-app-favorite
  • schneider/v1.17-changelog
  • schneider/ancs
  • schneider/png
  • schneider/freertos-list-debug
  • schneider/212-reset-hardware-when-entering-repl
  • schneider/bonding-fail-if-full
  • schneider/ble-fixes-2020-3
  • v1.18
  • v1.17
  • v1.16
  • v1.15
  • v1.14
  • v1.13
  • v1.12
  • v1.11
  • v1.10
  • v1.9
  • v1.8
  • v1.7
  • v1.6
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
41 results

stack_fit.c

Blame
  • doccompat.py 2.62 KiB
    # Copyright (c) 2016-2017, Jani Nikula <jani@nikula.org>
    # Licensed under the terms of BSD 2-Clause, see LICENSE for details.
    """
    Alternative docstring syntax
    ============================
    
    This module abstracts different compatibility options converting different
    syntaxes into 'native' reST ones.
    """
    
    import re
    
    # Basic Javadoc/Doxygen/kernel-doc import
    #
    # FIXME: One of the design goals of Hawkmoth is to keep things simple. There's a
    # fine balance between sticking to that goal and adding compat code to
    # facilitate any kind of migration to Hawkmoth. The compat code could be turned
    # into a fairly simple plugin architecture, with some basic compat builtins, and
    # the users could still extend the compat features to fit their specific needs.
    def convert(comment, mode):
        """Convert documentation from a supported syntax into reST."""
        # FIXME: try to preserve whitespace better
    
        if mode == 'javadoc-basic' or mode == 'javadoc-liberal':
            # @param
            comment = re.sub(r"(?m)^([ \t]*)@param([ \t]+)([a-zA-Z0-9_]+|\.\.\.)([ \t]+)",
                             "\n\\1:param\\2\\3:\\4", comment)
            # @param[direction]
            comment = re.sub(r"(?m)^([ \t]*)@param\[([^]]*)\]([ \t]+)([a-zA-Z0-9_]+|\.\.\.)([ \t]+)",
                             "\n\\1:param\\3\\4: *(\\2)* \\5", comment)
            # @return
            comment = re.sub(r"(?m)^([ \t]*)@returns?([ \t]+|$)",
                             "\n\\1:return:\\2", comment)
            # @code/@endcode blocks. Works if the code is indented.
            comment = re.sub(r"(?m)^([ \t]*)@code([ \t]+|$)",
                             "\n::\n", comment)
            comment = re.sub(r"(?m)^([ \t]*)@endcode([ \t]+|$)",
                             "\n", comment)
            # Ignore @brief.
            comment = re.sub(r"(?m)^([ \t]*)@brief[ \t]+", "\n\\1", comment)
    
            # Ignore groups
            comment = re.sub(r"(?m)^([ \t]*)@(defgroup|addtogroup)[ \t]+[a-zA-Z0-9_]+[ \t]*",
                             "\n\\1", comment)
            comment = re.sub(r"(?m)^([ \t]*)@(ingroup|{|}).*", "\n", comment)
    
        if mode == 'javadoc-liberal':
            # Liberal conversion of any @tags, will fail for @code etc. but don't
            # care.
            comment = re.sub(r"(?m)^([ \t]*)@([a-zA-Z0-9_]+)([ \t]+)",
                             "\n\\1:\\2:\\3", comment)
    
        if mode == 'kernel-doc':
            # Basic kernel-doc convert, will document struct members as params, etc.
            comment = re.sub(r"(?m)^([ \t]*)@(returns?|RETURNS?):([ \t]+|$)",
                             "\n\\1:return:\\3", comment)
            comment = re.sub(r"(?m)^([ \t]*)@([a-zA-Z0-9_]+|\.\.\.):([ \t]+)",
                             "\n\\1:param \\2:\\3", comment)
    
        return comment