File tree 5 files changed +36
-12
lines changed 5 files changed +36
-12
lines changed Original file line number Diff line number Diff line change @@ -111,3 +111,14 @@ You can display method source code appending the flag ``show-source``:
111
111
112
112
.. lua:autoclass:: pl.List
113
113
:show-source:
114
+
115
+
116
+ Showing private members
117
+ -------------------------------------------------------------------------------
118
+
119
+ By default, private members are hidden. You can display them by using the flag ``private-members ``:
120
+
121
+ .. code-block :: rst
122
+
123
+ .. lua:autoclass:: pl.List
124
+ :private-members:
Original file line number Diff line number Diff line change 32
32
install_requires = [
33
33
'six' ,
34
34
'Jinja2>3.0' ,
35
- 'luadoc>=1.3.0 ' ,
35
+ 'luadoc>=1.3.1 ' ,
36
36
'sphinxcontrib-luadomain>=1.1.1'
37
37
],
38
38
classifiers = [
Original file line number Diff line number Diff line change 26
26
27
27
{# display class field #}
28
28
{% for field in model.fields -%}
29
+ {%- if field.visibility == "public" or 'private-members' in options %}
29
30
{%- with type=field.type -%}
30
31
.. lua :attribute :: {{ field.name }}: {% include "type.rst" %}
31
32
32
33
{{ field.desc }}
33
34
34
35
{% endwith -%}
36
+ {%- endif %}
35
37
{%- endfor %}
36
38
37
39
{# display public methods first #}
38
40
{%- for method in model.methods -%}
39
- {%- if method.visibility == "public" %}
41
+ {%- if method.visibility == "public" or 'private-members' in options %}
40
42
{% include "method.rst" %}
41
43
{%- endif %}
42
44
{%- endfor %}
Original file line number Diff line number Diff line change 1
- .. lua :autoclass :: MyOrg.Car
1
+ .. lua :autoclass :: Class
2
+ :show-source:
3
+ :private-members:
Original file line number Diff line number Diff line change 1
- --- Define a car.
2
- --- @class MyOrg.Car
3
- local cls = class ()
1
+ --- @class Class
2
+ --- @field public some_public_field string This field is public
3
+ --- @field private _some_private_field string This field is private
4
+ local cls = {}
5
+ cls .__index = cls
4
6
5
- --- @param foo number
6
- function cls :test (foo )
7
+ --- Create a new Class
8
+ --- @return Class
9
+ function cls .new ()
10
+ return setmetatable ({
11
+ some_public_field = " public" ,
12
+ _some_private_field = " private" ,
13
+ }, cls )
7
14
end
8
15
9
- --- @param bar number
10
- function cls :_privateMember (bar )
16
+ --- Append the public field with `public`
17
+ function cls :more_public ()
18
+ self .some_public_field = self .some_public_field .. " public"
11
19
end
12
20
13
- --- @param bar number
14
- function cls :nn (bar )
21
+ --- Append the private field with `private`
22
+ function cls :_more_private ()
23
+ self ._some_private_field = self ._some_private_field .. " private"
15
24
end
You can’t perform that action at this time.
0 commit comments