Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indented function descriptions are not parsed #50

Open
rbairwell opened this issue Jul 28, 2022 · 0 comments · May be fixed by #72
Open

Indented function descriptions are not parsed #50

rbairwell opened this issue Jul 28, 2022 · 0 comments · May be fixed by #72

Comments

@rbairwell
Copy link
Contributor

rbairwell commented Jul 28, 2022

Given the following test file:

#!/usr/bin/env bash
# @file testdoc.sh
# @brief Demo
# @description Demonstration.

# @description Something
# something dark side.
#
# @example
#   testme()
#
# @noargs
testme() {
    echo "Hello"
}

if [[ 1 -eq 2 ]]; then

    # @description Another bit of
    # comment.
    #
    # @example
    #   testus()
    #
    # @noargs
    testus() {
        echo "Hello"
    }
fi

I would expect similar documentation output for both testme and testus - however, I get testus missing its description (but it does include the examples). I can't quite see why this is happening myself, but I'm not familiar with gawk.

Here is the output with debug mode enabled: using:

export SHDOC_DEBUG=1
shdoc testdoc.sh

DEBUG: line: [#!/usr/bin/env bash]
DEBUG: → NOT HANDLED
DEBUG: line: [# @file testdoc.sh]
DEBUG: → @name|@file
DEBUG: line: [# @brief Demo]
DEBUG: → @brief
DEBUG: line: [# @description Demonstration.]
DEBUG: → @description
DEBUG: → handle_description
DEBUG: → → description: empty
DEBUG: → reset()
DEBUG: → → in_description: concat
DEBUG: line: []
DEBUG: → → in_description: leave
DEBUG: → handle_description
DEBUG: → → description: added
DEBUG: → break
DEBUG: → handle_description
DEBUG: → reset()
DEBUG: line: [# @description Something]
DEBUG: → @description
DEBUG: → handle_description
DEBUG: → → description: empty
DEBUG: → reset()
DEBUG: → → in_description: concat
DEBUG: line: [# something dark side.]
DEBUG: → → in_description: concat
DEBUG: line: [#]
DEBUG: → → in_description: concat
DEBUG: line: [# @example]
DEBUG: → → in_description: leave
DEBUG: → handle_description
DEBUG: → @example
DEBUG: line: [#   testme()]
DEBUG: → → in_example: concat
DEBUG: line: [#]
DEBUG: → → in_example: leave
DEBUG: → NOT HANDLED
DEBUG: line: [# @noargs]
DEBUG: → @noargs
DEBUG: line: [testme() {]
DEBUG: → function
DEBUG: → → function: register
DEBUG: → render_docblock
DEBUG: → → func_name: [testme]
DEBUG: → → description: [Something
something dark side.
]
DEBUG: → reset()
DEBUG: line: [    echo "Hello"]
DEBUG: → break
DEBUG: → handle_description
DEBUG: → → description: empty
DEBUG: → reset()
DEBUG: line: [}]
DEBUG: → break
DEBUG: → handle_description
DEBUG: → → description: empty
DEBUG: → reset()
DEBUG: line: []
DEBUG: → break
DEBUG: → handle_description
DEBUG: → → description: empty
DEBUG: → reset()
DEBUG: line: [if [[ 1 -eq 2 ]]; then]
DEBUG: → break
DEBUG: → handle_description
DEBUG: → → description: empty
DEBUG: → reset()
DEBUG: line: []
DEBUG: → break
DEBUG: → handle_description
DEBUG: → → description: empty
DEBUG: → reset()
DEBUG: line: [    # @description Another bit of]
DEBUG: → @description
DEBUG: → handle_description
DEBUG: → → description: empty
DEBUG: → reset()
DEBUG: → → in_description: leave
DEBUG: → handle_description
DEBUG: → NOT HANDLED
DEBUG: line: [    # comment.]
DEBUG: → NOT HANDLED
DEBUG: line: [    #]
DEBUG: → NOT HANDLED
DEBUG: line: [    # @example]
DEBUG: → @example
DEBUG: line: [    #   testus()]
DEBUG: → → in_example: concat
DEBUG: line: [    #]
DEBUG: → → in_example: leave
DEBUG: → NOT HANDLED
DEBUG: line: [    # @noargs]
DEBUG: → @noargs
DEBUG: line: [    testus() {]
DEBUG: → function
DEBUG: → → function: register
DEBUG: → render_docblock
DEBUG: → → func_name: [testus]
DEBUG: → → description: [
]
DEBUG: → reset()
DEBUG: line: [        echo "Hello"]
DEBUG: → break
DEBUG: → handle_description
DEBUG: → → description: empty
DEBUG: → reset()
DEBUG: line: [    }]
DEBUG: → break
DEBUG: → handle_description
DEBUG: → → description: empty
DEBUG: → reset()
DEBUG: line: [fi]
DEBUG: → break
DEBUG: → handle_description
DEBUG: → → description: empty
DEBUG: → reset()
DEBUG: → END {
DEBUG: → → file_title:       [testdoc.sh]
DEBUG: → → file_brief:       [Demo]
DEBUG: → → file_description: [Demonstration.
]
DEBUG: → END }
# testdoc.sh

Demo

## Overview

Demonstration.

## Index

* [testme](#testme)
* [testus](#testus)

### testme

Something
something dark side.

#### Example

'''bash
testme()
'''

_Function has no arguments._

### testus



#### Example

'''bash
testus()
'''

_Function has no arguments._

[note: I did change the backslashes in the outputted code samples to be single quote marks to avoid Github handling it as formatting]

Platform
Docker: debian:bullseye
GNU Awk version: 5.1.0 API: 3.0
shdoc commit version 433a0ba (6th April)

(And before anyone asks, no that is not real in use code, but I've just reduced it down to a test case - there is a reason I've got a function within an if statement and it is formatted by shfmt, checked by shellcheck and runs on in my Bash 5 environment - so I think it's valid code ;) )

( How did I miss #21 ? )

landure added a commit to landure/shdoc that referenced this issue Nov 12, 2022
- Add common code for multiline support for:
  description, example, stdout, stderr, stdin, set, see, and exitcode.
landure added a commit to landure/shdoc that referenced this issue Aug 19, 2023
- Add common code for multiline support for:
  description, example, stdout, stderr, stdin, set, see, and exitcode.
landure added a commit to landure/shdoc that referenced this issue Aug 19, 2023
- Add common code for multiline support for:
  description, example, stdout, stderr, stdin, set, see, and exitcode.
- `li-preprocess` style adds indentation to multiple line list entries.
- replace space by generic `[[:blank:]]` in `exitcode` style `from`
  regex.
@landure landure linked a pull request Aug 19, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant