Browse Source

Add SFDOC_HIDE_REGEX to enable overriding definition of "hidden"

Alois Mahdal 4 years ago
parent
commit
32bdba11b9
2 changed files with 19 additions and 3 deletions
  1. 18
    3
      src/include-bash/sfdoc.sh
  2. 1
    0
      tests/shellfu_api/oracle/variables.stdout

+ 18
- 3
src/include-bash/sfdoc.sh View File

23
 # with `_` (underscore).  These are ignored by default.  Set this to 'true' to show
23
 # with `_` (underscore).  These are ignored by default.  Set this to 'true' to show
24
 # them.
24
 # them.
25
 #
25
 #
26
+# See also $SFDOC_HIDE_REGEX.
27
+#
26
 SFDOC_SHOW_HIDDEN=${SFDOC_SHOW_HIDDEN:-false}
28
 SFDOC_SHOW_HIDDEN=${SFDOC_SHOW_HIDDEN:-false}
27
 
29
 
30
+#
31
+# Regex to override what is hidden
32
+#
33
+# Override definition of which objects are considered "private", thus hidden
34
+# by default.  Regular expression is used as Extended Regular Expressions,
35
+# is anchored on both sides and case-sensitive, e setting 'foo|bAr' matches
36
+# only objects whose entire name is either 'foo' or 'bAr'.
37
+#
38
+# See also $SFDOC_SHOW_HIDDEN.
39
+#
40
+SFDOC_HIDE_REGEX=${SFDOC_HIDE_REGEX:-_.*}
41
+
28
 sfdoc__export() {
42
 sfdoc__export() {
29
     #
43
     #
30
     # Export docs of module $2 from file $3 as format $3
44
     # Export docs of module $2 from file $3 as format $3
345
     #
359
     #
346
     local what=$1
360
     local what=$1
347
     $SFDOC_SHOW_HIDDEN && cat && return
361
     $SFDOC_SHOW_HIDDEN && cat && return
362
+    debug -v SFDOC_HIDE_REGEX
348
     case $what in
363
     case $what in
349
-        m)  grep -v ^_ ;;
350
-        v)  grep -v :_ ;;
351
-        f)  grep -v :_ ;;
364
+        m)  grep -vE "^$SFDOC_HIDE_REGEX$" ;;
365
+        v)  grep -vE ":$SFDOC_HIDE_REGEX$" ;;
366
+        f)  grep -vE ":$SFDOC_HIDE_REGEX$" ;;
352
         *)  warn "bug: invalid object type: $otype" ;;
367
         *)  warn "bug: invalid object type: $otype" ;;
353
     esac
368
     esac
354
 }
369
 }

+ 1
- 0
tests/shellfu_api/oracle/variables.stdout View File

22
 pretty:PRETTY_DEBUG_EXCLUDE
22
 pretty:PRETTY_DEBUG_EXCLUDE
23
 pretty:PRETTY_USAGE
23
 pretty:PRETTY_USAGE
24
 pretty:PRETTY_VERBOSE
24
 pretty:PRETTY_VERBOSE
25
+sfdoc:SFDOC_HIDE_REGEX
25
 sfdoc:SFDOC_SHOW_HIDDEN
26
 sfdoc:SFDOC_SHOW_HIDDEN
26
 sfpi:SFPI__PREFIX
27
 sfpi:SFPI__PREFIX
27
 termcolors:TERMCOLORS_BLACK
28
 termcolors:TERMCOLORS_BLACK