bash - 如何记录shell函数?

标签 bash function shell documentation

<分区>

我正在寻找某种格式来描述 shell 脚本中的函数。 例如。在 PHP 中:

/**
 * My description
 *
 * @param string $paramOne Some extra comment for this parameter
 * @param int    $paramTwo
 * @return $this
 */
function myCoolFunc($paramOne, $paramTwo)
{
}

有文档格式吗?

UPD 1 我不是在寻找文档处理器。只是格式化。

应该是这样的:

# Simple yes/no dialog question
#
# e.g.: $(dialog_yes_no 'Would like to repeat?' 'n' 3)
#
# string question
# string default
# int mistakes_count = 5
function dialog_yes_no
{
}

最佳答案

我确实使用以下格式,你可以开始使用这种格式,它类似于 unix/linux 使用的 man/info。

#!/bin/ksh
#================================================================
# HEADER
#================================================================
#% SYNOPSIS
#+    ${SCRIPT_NAME} [-hv] [-o[file]] args ...
#%
#% DESCRIPTION
#%    This is a script template
#%    to start any good shell script.
#%
#% OPTIONS
#%    -o [file], --output=[file]    Set log file (default=/dev/null)
#%                                  use DEFAULT keyword to autoname file
#%                                  The default value is /dev/null.
#%    -t, --timelog                 Add timestamp to log ("+%y/%m/%d@%H:%M:%S")
#%    -x, --ignorelock              Ignore if lock file exists
#%    -h, --help                    Print this help
#%    -v, --version                 Print script information
#%
#% EXAMPLES
#%    ${SCRIPT_NAME} -o DEFAULT arg1 arg2
#%
#================================================================
#- IMPLEMENTATION
#-    version         ${SCRIPT_NAME} (www.uxora.com) 0.0.4
#-    author          Michel VONGVILAY
#-    copyright       Copyright (c) http://www.uxora.com
#-    license         GNU General Public License
#-    script_id       12345
#-
#================================================================
#  HISTORY
#     2015/03/01 : mvongvilay : Script creation
#     2015/04/01 : mvongvilay : Add long options and improvements
# 
#================================================================
#  DEBUG OPTION
#    set -n  # Uncomment to check your syntax, without execution.
#    set -x  # Uncomment to debug this shell script
#
#================================================================
# END_OF_HEADER
#================================================================

关于bash - 如何记录shell函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32657065/

相关文章:

bash - sed 在一条线上工作,但不在另一条线上

mysql - 带有 `/bin/bash -c` 运行 mysql 守护进程的 Docker

去除时间序列中不会持续特定时间范围的噪声

javascript - 切换类函数仅适用于第一个元素

Linux - 如何用大括号括起来的相同字符串替换一些字符串?

java - 如何使用 java 将参数传递给 shell 脚本?

linux - -> result=$(ls -l) (or) -> result =`ls -l` 有什么区别

bash - 仅使用 Bash 模式匹配从字符串开头删除模式

ruby - Ruby 中的 While 循环和转换为函数

php - 如何将 json 或类对象传递给命令行 php 脚本