summary refs log tree commit diff stats
path: root/nimdoc/testproject/subdir/subdir_b/utils.nim
blob: e201a3d3884a0c13f12dd2073fa655d676ad6038 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
##[

.. include:: ./utils_overview.rst

# This is now a header

## Next header

### And so on

# More headers

###### Up to level 6


#. An enumeration
#. Second idea here.

More text.

1. Other case value
2. Second case.

Ref group fn2_ or specific function like `fn2()`_
or `fn2(  int  )`_ or `fn2(int,
float)`_.

Ref generics like this: binarySearch_ or `binarySearch(openArray[T], K,
proc (T, K))`_ or `proc binarySearch(openArray[T], K,  proc (T, K))`_ or
in different style: `proc binarysearch(openarray[T], K, proc(T, K))`_.
Can be combined with export symbols and type parameters:
`binarysearch*[T, K](openArray[T], K, proc (T, K))`_.
With spaces `binary search`_.

Note that `proc` can be used in postfix form: `binarySearch proc`_.

Ref. type like G_ and `type G`_ and `G[T]`_ and `type G*[T]`_.

Group ref. with capital letters works: fN11_ or fn11_
]##

include ./utils_helpers

type
  SomeType* = enum
    enumValueA,
    enumValueB,
    enumValueC
  G*[T] = object
    val: T

proc someType*(): SomeType =
  ## constructor.
  SomeType(2)


proc fn2*() = discard ## comment
proc fn2*(x: int) =
  ## fn2 comment
  discard
proc fn2*(x: int, y: float) =
  discard
proc binarySearch*[T, K](a: openArray[T]; key: K;
                         cmp: proc (x: T; y: K): int {.closure.}): int =
  discard
proc fn3*(): auto = 1 ## comment
proc fn4*(): auto = 2 * 3 + 4 ## comment
proc fn5*() ## comment
proc fn5*() = discard
proc fn6*() =
  ## comment
proc fn7*() =
  ## comment
  discard
proc fn8*(): auto =
  ## comment
  1+1
func fn9*(a: int): int = 42  ## comment
func fn10*(a: int): int = a  ## comment

# Note capital letter N will be handled correctly in
# group references like fN11_ or fn11_:
func fN11*() = discard
func fN11*(x: int) = discard

# bug #9235

template aEnum*(): untyped =
  type
    A* {.inject.} = enum ## The enum A.
      aA

template bEnum*(): untyped =
  type
    B* {.inject.} = enum ## The enum B.
      bB

  func someFunc*() =
    ## My someFunc.
    ## Stuff in `quotes` here.
    ## [Some link](https://nim-lang.org)
    discard

template fromUtilsGen*(): untyped =
  ## should be shown in utils.html only
  runnableExamples:
    discard "should be in utils.html only, not in module that calls fromUtilsGen"
  ## ditto

  iterator fromUtils1*(): int =
    runnableExamples:
      # ok1
      assert 1 == 1
      # ok2
    yield 15

  template fromUtils2*() =
    ## ok3
    runnableExamples:
      discard """should be shown as examples for fromUtils2
       in module calling fromUtilsGen"""

  proc fromUtils3*() =
    ## came form utils but should be shown where `fromUtilsGen` is called
    runnableExamples: discard """should be shown as examples for fromUtils3
       in module calling fromUtilsGen"""

proc f*(x: G[int]) =
  ## There is also variant `f(G[string])`_
  discard
proc f*(x: G[string]) =
  ## See also `f(G[int])`_.
  discard

## Ref. `[]`_ is the same as `proc \`[]\`(G[T])`_ because there are no
## overloads. The full form: `proc \`[]\`*[T](x: G[T]): T`_

proc `[]`*[T](x: G[T]): T = x.val

## Ref. `[]=`_ aka `\`[]=\`(G[T], int, T)`_.

proc `[]=`*[T](a: var G[T], index: int, value: T) = discard

## Ref. `$`_ aka `proc $`_ or `proc \`$\``_.

proc `$`*[T](a: G[T]): string = ""

## Ref. `$(a: ref SomeType)`_.

proc `$`*[T](a: ref SomeType): string = ""

## Ref. foo_bar_ aka `iterator foo_bar_`_.

iterator fooBar*(a: seq[SomeType]): int = discard

## Ref. `fn[T; U,V: SomeFloat]()`_.

proc fn*[T; U, V: SomeFloat]() = discard

## Ref. `'big`_ or `func \`'big\``_ or `\`'big\`(string)`_.

func `'big`*(a: string): SomeType = discard