source: rtems-central/rtemsspec/tests/test_interfacedoc.py @ 0500b9a

Last change on this file since 0500b9a was 0500b9a, checked in by Sebastian Huber <sebastian.huber@…>, on 12/01/20 at 13:23:41

interface/interfacedoc: Format parameter names

  • Property mode set to 100644
File size: 10.6 KB
Line 
1# SPDX-License-Identifier: BSD-2-Clause
2""" Unit tests for the rtemsspec.interfacedoc module. """
3
4# Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12#    notice, this list of conditions and the following disclaimer in the
13#    documentation and/or other materials provided with the distribution.
14#
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25# POSSIBILITY OF SUCH DAMAGE.
26
27import os
28import pytest
29
30from rtemsspec.interfacedoc import generate
31from rtemsspec.items import EmptyItemCache, ItemCache
32from rtemsspec.tests.util import create_item_cache_config_and_copy_spec
33
34
35def test_interfacedoc(tmpdir):
36    doc_config = {}
37    doc_config["group"] = "/gb"
38    introduction_rst = os.path.join(tmpdir, "introduction.rst")
39    doc_config["introduction-target"] = introduction_rst
40    directives_rst = os.path.join(tmpdir, "directives.rst")
41    doc_config["directives-target"] = directives_rst
42
43    doc_config_2 = {}
44    doc_config_2["group"] = "/ga"
45    introduction_2_rst = os.path.join(tmpdir, "introduction-2.rst")
46    doc_config_2["introduction-target"] = introduction_2_rst
47    directives_2_rst = os.path.join(tmpdir, "directives-2.rst")
48    doc_config_2["directives-target"] = directives_2_rst
49
50    item_cache_config = create_item_cache_config_and_copy_spec(
51        tmpdir, "spec-interface", with_spec_types=True)
52    generate([doc_config, doc_config_2], ItemCache(item_cache_config))
53
54    with open(introduction_rst, "r") as src:
55        content = """.. SPDX-License-Identifier: CC-BY-SA-4.0
56
57.. Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
58
59.. This file is part of the RTEMS quality process and was automatically
60.. generated.  If you find something that needs to be fixed or
61.. worded better please post a report or patch to an RTEMS mailing list
62.. or raise a bug report:
63..
64.. https://docs.rtems.org/branches/master/user/support/bugs.html
65..
66.. For information on updating and regenerating please refer to:
67..
68.. https://docs.rtems.org/branches/master/eng/req/howto.html
69
70.. Generated from spec:/gb
71
72.. _GroupBIntroduction:
73
74Introduction
75============
76
77.. The following list was generated from:
78.. spec:/func4
79.. spec:/func2
80.. spec:/func3
81.. spec:/macro
82.. spec:/macro2
83.. spec:/macro3
84
85The directives provided by the Group B are:
86
87* :ref:`InterfaceVeryLongTypeFunction` - Function brief description with very
88  long return type.
89
90* :ref:`InterfaceVeryLongFunction` - Very long function brief description.
91
92* :ref:`InterfaceVoidFunction`
93
94* :ref:`InterfaceVERYLONGMACRO` - Very long macro brief description.
95
96* :ref:`InterfaceMACRO` - Short macro brief description.
97
98* :ref:`InterfaceMACRO` - Macro without parameters.
99"""
100        assert content == src.read()
101
102    with open(directives_rst, "r") as src:
103        content = """.. SPDX-License-Identifier: CC-BY-SA-4.0
104
105.. Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
106
107.. This file is part of the RTEMS quality process and was automatically
108.. generated.  If you find something that needs to be fixed or
109.. worded better please post a report or patch to an RTEMS mailing list
110.. or raise a bug report:
111..
112.. https://docs.rtems.org/branches/master/user/support/bugs.html
113..
114.. For information on updating and regenerating please refer to:
115..
116.. https://docs.rtems.org/branches/master/eng/req/howto.html
117
118.. _GroupBDirectives:
119
120Directives
121==========
122
123This section details the directives of the Group B. A subsection is dedicated
124to each of this manager's directives and lists the calling sequence,
125parameters, description, return values, and notes of the directive.
126
127.. Generated from spec:/func4
128
129.. raw:: latex
130
131    \\clearpage
132
133.. index:: VeryLongTypeFunction()
134
135.. _InterfaceVeryLongTypeFunction:
136
137VeryLongTypeFunction()
138----------------------
139
140Function brief description with very long return type.
141
142.. rubric:: CALLING SEQUENCE:
143
144.. code-block:: c
145
146    #if 1
147      NotSoVeryLongType VeryLongTypeFunction( void );
148    #else
149      VeryLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongType
150      VeryLongTypeFunction( void );
151    #endif
152
153.. rubric:: RETURN VALUES:
154
155This function returns an object with a very long type.
156
157.. Generated from spec:/func2
158
159.. raw:: latex
160
161    \\clearpage
162
163.. index:: VeryLongFunction()
164
165.. _InterfaceVeryLongFunction:
166
167VeryLongFunction()
168------------------
169
170Very long function brief description.
171
172.. rubric:: CALLING SEQUENCE:
173
174.. code-block:: c
175
176    int VeryLongFunction(
177      int                  VeryLongParam0,
178      const struct Struct *VeryLongParam1,
179      struct Struct    *( *VeryLongParam2 )( void ),
180      struct Struct       *VeryLongParam3
181    );
182
183.. rubric:: PARAMETERS:
184
185``VeryLongParam0``
186    This parameter is very long parameter 0 with some super important and extra
187    very long description which makes a lot of sense.
188
189``VeryLongParam1``
190    This parameter is very long parameter 1.
191
192``VeryLongParam2``
193    This parameter is very long parameter 2.
194
195``VeryLongParam3``
196    This parameter is very long parameter 3.
197
198.. rubric:: DESCRIPTION:
199
200VeryLongFunction description.
201
202.. rubric:: RETURN VALUES:
203
204``1``
205    is returned, in case A.
206
207``2``
208    is returned, in case B.
209
210:c:type:`Enum`
211    is returned, in case C.
212
213Sometimes some value.  See :ref:`InterfaceFunction`.
214
215.. rubric:: NOTES:
216
217VeryLongFunction notes.
218
219.. Generated from spec:/func3
220
221.. raw:: latex
222
223    \\clearpage
224
225.. index:: VoidFunction()
226
227.. _InterfaceVoidFunction:
228
229VoidFunction()
230--------------
231
232.. rubric:: CALLING SEQUENCE:
233
234.. code-block:: c
235
236    #if 1
237      void VoidFunction( void );
238    #endif
239
240.. Generated from spec:/macro
241
242.. raw:: latex
243
244    \\clearpage
245
246.. index:: VERY_LONG_MACRO()
247
248.. _InterfaceVERYLONGMACRO:
249
250VERY_LONG_MACRO()
251-----------------
252
253Very long macro brief description.
254
255.. rubric:: CALLING SEQUENCE:
256
257.. code-block:: c
258
259    #define VERY_LONG_MACRO(
260      VeryLongParam0,
261      VeryLongParam1,
262      VeryLongParam2,
263      VeryLongParam3
264    )
265
266.. rubric:: PARAMETERS:
267
268``VeryLongParam0``
269    This parameter is very long parameter 0 with some super important and extra
270    very long description which makes a lot of sense.
271
272``VeryLongParam1``
273    This parameter is very long parameter 1.
274
275``VeryLongParam2``
276    This parameter is very long parameter 2.
277
278``VeryLongParam3``
279    This parameter is very long parameter 3.
280
281.. rubric:: RETURN VALUES:
282
283``1``
284    is returned, in case A.
285
286``2``
287    is returned, in case B.
288
289Sometimes some value.
290
291.. Generated from spec:/macro2
292
293.. raw:: latex
294
295    \\clearpage
296
297.. index:: MACRO()
298
299.. _InterfaceMACRO:
300
301MACRO()
302-------
303
304Short macro brief description.
305
306.. rubric:: CALLING SEQUENCE:
307
308.. code-block:: c
309
310    #if defined(0)
311      #define MACRO( Param0 )
312    #else
313      #define MACRO( Param0 )
314    #endif
315
316.. rubric:: PARAMETERS:
317
318``Param0``
319    This parameter is parameter 0.
320
321.. rubric:: RETURN VALUES:
322
323Sometimes some value.
324
325.. Generated from spec:/macro3
326
327.. raw:: latex
328
329    \\clearpage
330
331.. index:: MACRO()
332
333.. _InterfaceMACRO:
334
335MACRO()
336-------
337
338Macro without parameters.
339
340.. rubric:: CALLING SEQUENCE:
341
342.. code-block:: c
343
344    #define MACRO()
345"""
346        assert content == src.read()
347
348    with open(introduction_2_rst, "r") as src:
349        content = """.. SPDX-License-Identifier: CC-BY-SA-4.0
350
351.. Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
352
353.. This file is part of the RTEMS quality process and was automatically
354.. generated.  If you find something that needs to be fixed or
355.. worded better please post a report or patch to an RTEMS mailing list
356.. or raise a bug report:
357..
358.. https://docs.rtems.org/branches/master/user/support/bugs.html
359..
360.. For information on updating and regenerating please refer to:
361..
362.. https://docs.rtems.org/branches/master/eng/req/howto.html
363
364.. Generated from spec:/ga
365
366.. _GroupAIntroduction:
367
368Introduction
369============
370
371.. The following list was generated from:
372.. spec:/func
373
374Group A brief description.
375
376Group A description. The directives provided by the Group A are:
377
378* :ref:`InterfaceFunction` - Function brief description.
379"""
380        assert content == src.read()
381
382    with open(directives_2_rst, "r") as src:
383        content = """.. SPDX-License-Identifier: CC-BY-SA-4.0
384
385.. Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
386
387.. This file is part of the RTEMS quality process and was automatically
388.. generated.  If you find something that needs to be fixed or
389.. worded better please post a report or patch to an RTEMS mailing list
390.. or raise a bug report:
391..
392.. https://docs.rtems.org/branches/master/user/support/bugs.html
393..
394.. For information on updating and regenerating please refer to:
395..
396.. https://docs.rtems.org/branches/master/eng/req/howto.html
397
398.. _GroupADirectives:
399
400Directives
401==========
402
403This section details the directives of the Group A. A subsection is dedicated
404to each of this manager's directives and lists the calling sequence,
405parameters, description, return values, and notes of the directive.
406
407.. Generated from spec:/func
408
409.. raw:: latex
410
411    \\clearpage
412
413.. index:: Function()
414
415.. _InterfaceFunction:
416
417Function()
418----------
419
420Function brief description.
421
422.. rubric:: CALLING SEQUENCE:
423
424.. code-block:: c
425
426    void Function( int Param0, const int *Param1, int *Param2, int *Param3 );
427
428.. rubric:: PARAMETERS:
429
430``Param0``
431    This parameter is parameter 0.
432
433``Param1``
434    This parameter is parameter 1.
435
436``Param2``
437    This parameter is parameter 2.
438
439``Param3``
440    This parameter is parameter 3.
441
442.. rubric:: DESCRIPTION:
443
444Function description.  References to :ref:`InterfaceVeryLongFunction`,
445:c:type:`Integer`, :c:type:`Enum`, :c:macro:`DEFINE`,
446:ref:`InterfaceVERYLONGMACRO`, Variable, :c:macro:`ENUMERATOR_0`,
447:c:type:`Struct`, :ref:`a`, and interface. Second parameter is ``Param1``.
448"""
449        assert content == src.read()
Note: See TracBrowser for help on using the repository browser.