Skip to content

Commit 41f933a

Browse files
committed
Added plc:gvl directive
1 parent 73905e6 commit 41f933a

File tree

6 files changed

+61
-1
lines changed

6 files changed

+61
-1
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Documentation Status](https://readthedocs.org/projects/plc-doc/badge/?version=latest)](https://plc-doc.readthedocs.io/latest/?badge=latest)
44
[![Unit tests](https://github.com/DEMCON/plcdoc/actions/workflows/tests.yml/badge.svg)](https://github.com/DEMCON/plcdoc/actions)
5-
[![codecov](https://codecov.io/github/DEMCON/plcdoc/graph/badge.svg?token=LS0LECRP58)](https://codecov.io/DEMCON/plcdoc)
5+
[![codecov](https://codecov.io/gh/DEMCON/plcdoc/graph/badge.svg?token=xMg0U6mX2r)](https://codecov.io/gh/DEMCON/plcdoc)
66

77
This is a work-in-progress of a tool to get documentation with Sphinx from TwinCAT PLC.
88
The focus is on PLC code made with Structured Text (ST), i.e. the IEC 61131-3 standard.

Diff for: docs/src/directives.rst

+32
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,16 @@ The same options from `function <#function>`_ are available.
8282
:var_input LREAL myInput:
8383
:var_output LREAL myOutput:
8484
85+
Description of my function block.
86+
8587
.. functionblock:: MyFunctionBlock
8688
:noindex:
8789

8890
:var_input LREAL myInput:
8991
:var_output LREAL myOutput:
9092

93+
Description of my function block.
94+
9195
You can also nest e.g. methods and properties:
9296

9397
.. code-block:: rst
@@ -197,6 +201,34 @@ struct
197201
.. member:: Second : LREAL
198202
:noindex:
199203

204+
gvl
205+
---
206+
207+
.. code-block:: rst
208+
209+
.. gvl:: <name>
210+
211+
<variables>
212+
213+
**Examples:**
214+
215+
.. code-block:: rst
216+
217+
.. gvl:: GVL_Main
218+
219+
:var LREAL var_double: Some precision decimal variable
220+
:var BOOL my_flag: Another variable, of boolean type
221+
222+
Main variables list.
223+
224+
.. gvl:: GVL_Main
225+
:noindex:
226+
227+
:var LREAL var_double: Some precision decimal variable
228+
:var BOOL my_flag: Another variable, of boolean type
229+
230+
Main variables list.
231+
200232
folder
201233
------
202234

Diff for: src/plcdoc/directives.py

+17
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,23 @@ class PlcMemberDescription(PlcObjectDescription):
253253
object_display_type = False
254254

255255

256+
class PlcVariableListDescription(PlcObjectDescription):
257+
"""Directive specifically to show a GVL."""
258+
259+
# fmt: off
260+
doc_field_types = [
261+
TypedField(
262+
"var",
263+
label="VAR",
264+
names=("var", "param", "parameter", "arg", "argument"),
265+
typerolename="type",
266+
typenames=("paramtype", "type", "var_type"),
267+
can_collapse=False,
268+
),
269+
]
270+
# fmt: on
271+
272+
256273
class PlcFolderDescription(PlcObjectDescription):
257274
"""Directive specifically for a folder and contents."""
258275

Diff for: src/plcdoc/domain.py

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
PlcEnumeratorDescription,
1919
PlcMemberDescription,
2020
PlcFolderDescription,
21+
PlcVariableListDescription,
2122
)
2223
from .roles import PlcXRefRole
2324

@@ -61,6 +62,7 @@ class StructuredTextDomain(Domain):
6162
"struct": PlcObjectDescription,
6263
"member": PlcMemberDescription,
6364
"property": PlcObjectDescription,
65+
"gvl": PlcVariableListDescription,
6466
"folder": PlcFolderDescription,
6567
}
6668

Diff for: tests/roots/test-domain-plc/index.rst

+8
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,11 @@
5858
.. plc:property:: \
5959
FaceUp
6060
FaceDown
61+
62+
63+
.. GVL -----------------------------
64+
65+
.. plc:gvl:: GVL_MyList
66+
67+
:var LREAL my_double: Some double-type variable
68+
:var USINT some_int: My short integer

Diff for: tests/test_domain_plc.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ def test_domain_plc_objects(app, status, warning):
1818
assert objects["Orientation"][2] == "enum"
1919
assert objects["ST_MyStruct"][2] == "struct"
2020
assert objects["ST_MyStruct2"][2] == "struct"
21+
assert objects["GVL_MyList"][2] == "gvl"

0 commit comments

Comments
 (0)