Part 1
요약·해설
@verify·@satisfy custom directive, all_tests/tests_ group 규칙, Doxygen XML build 과정을 예제 그대로 설명합니다.
Doxygen XML
@verify requirement
@satisfy coverage
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
A9AC33FAB3B6D4AA1BC540B010C5320E683F5A0DB8A5D9C6170AC7424411FECC
.. _code-documentation:
Code Documentation
###################
API Documentation
******************
Well documented APIs enhance the experience for developers and are an essential
requirement for defining an API's success. Doxygen is a general purpose
documentation tool that the zephyr project uses for documenting APIs. It
generates either an on-line documentation browser (in HTML) and/or provides
input for other tools that is used to generate a reference manual from
documented source files. In particular, doxygen's XML output is used as an input
when producing the Zephyr project's online documentation.
Reference to Requirements
**************************
APIs for the most part document the implementation of requirements or advertised
features and can be traced back to features. We use the API documentation as the
main interface to trace implementation back to documented features. This is done
using custom _doxygen_ tags that reference requirements maintained somewhere
else in a requirement catalogue.
Test Documentation
*******************
To help understand what each test does and which functionality it tests we also
document all test code using the same tools and in the same context and generate
documentation for all unit and integration tests maintained in the same
environment. Tests are documented using references to the APIs or functionality
they validate by creating a link back to the APIs and by adding a reference to
the original requirements.
Documentation Guidelines
*************************
Test Code
=========
The Zephyr project uses several test methodologies, the most common being the
:ref:`Ztest framework <test-framework>`. Test documentation should only be done
on the entry test functions (usually prefixed with test\_) and those that are
called directly by the Ztest framework. Those tests are going to appear in test
reports and using their name and identifier is the best way to identify them
and trace back to them from requirements.
Test documentation should not interfere with the actual API documentation and
needs to follow a new structure to avoid confusion. Using a consistent naming
scheme and following a well-defined structure we will be able to group this
documentation in its own module and identify it uniquely when parsing test data
for traceability reports. Here are a few guidelines to be followed:
- All test code documentation should be grouped under the ``all_tests`` doxygen
group
- All test documentation should be under doxygen groups that are prefixed
with tests\_
The custom doxygen ``@verify`` directive signifies that a test verifies a
requirement::
/**
* @brief Tests for the Semaphore kernel object
* @defgroup kernel_semaphore_tests Semaphore
* @ingroup all_tests
* @{
*/
...
/**
* @brief A brief description of the tests
* Some details about the test
* more details
*
* @verify{@req{1111}}
*/
void test_sema_thread2thread(void)
{
...
}
...
/**
* @}
*/
To get coverage of how an implementation or a piece of code satisfies a
requirements, we use the ``satisfy`` alias in doxygen::
/**
* @brief Give a semaphore.
*
* This routine gives @a sem, unless the semaphore is already at its maximum
* permitted count.
*
* @note Can be called by ISRs.
*
* @param sem Address of the semaphore.
*
* @satisfy{@req{015}}
*/
__syscall void k_sem_give(struct k_sem *sem);
To generate the matrix, you will first need to build the documentation,
specifically you will need to build the doxygen XML output::
$ make doxygen
Parse the generated XML data from doxygen to generate the traceability matrix.
Part 3
한국어 전문 번역
API Documentation
잘 문서화된 API는 developer experience를 높이고 API 성공을 정의하는 데 필수적입니다. Zephyr project는 general-purpose documentation tool인 Doxygen으로 API를 문서화합니다. Doxygen은 HTML online documentation browser를 만들거나, documented source file에서 reference manual을 생성하는 다른 tool의 input을 제공합니다. 특히 Doxygen XML output은 Zephyr online documentation을 만들 때 input으로 사용합니다.
Requirement 참조
API는 대부분 requirement 또는 공개된 feature의 implementation을 문서화하며 feature까지 추적할 수 있습니다. Zephyr는 API documentation을 implementation에서 documented feature로 거슬러 올라가는 main interface로 사용합니다. Requirement catalogue의 다른 위치에서 관리되는 requirement를 가리키는 custom Doxygen tag로 이 관계를 만듭니다.
Test Documentation
각 test가 무엇을 하고 어떤 functionality를 검사하는지 이해할 수 있도록 모든 test code도 같은 tool과 context로 문서화합니다. 같은 environment에서 관리되는 모든 unit·integration test의 documentation을 생성합니다. Test가 검증하는 API 또는 functionality로 link를 만들고 original requirement reference를 추가해 test를 문서화합니다.
@req identifier
@satisfy로 requirement 충족
@verify로 requirement 검증
API·test relation 추출
requirement ↔ implementation ↔ test
API documentation과 test report를 같은 identifier로 연결합니다.
Documentation Guidelines
Test Code
Zephyr project는 여러 test methodology를 사용하며 가장 흔한 것은 Ztest framework입니다. Test documentation은 entry test function, 보통 test_ prefix가 붙고 Ztest framework가 직접 호출하는 function에만 작성해야 합니다. 이 test들이 test report에 나타나므로 function name과 identifier가 requirement에서 test로 추적하는 가장 좋은 표식입니다.
Test documentation은 실제 API documentation을 방해하면 안 되며 혼동을 피하도록 별도 구조를 따라야 합니다. Consistent naming scheme과 well-defined structure를 사용하면 test documentation을 독립 module로 묶고 traceability report용 test data를 parse할 때 고유하게 식별할 수 있습니다.
- 모든 test-code documentation은
all_testsDoxygen group 아래에 묶습니다. - 모든 test documentation은
tests_prefix가 붙은 Doxygen group 아래에 둡니다.
Custom Doxygen @verify directive는 test가 requirement를 검증한다는 뜻입니다.
/**
* @brief Tests for the Semaphore kernel object
* @defgroup kernel_semaphore_tests Semaphore
* @ingroup all_tests
* @{
*/
...
/**
* @brief A brief description of the tests
* Some details about the test
* more details
*
* @verify{@req{1111}}
*/
void test_sema_thread2thread(void)
{
...
}
...
/**
* @}
*/Implementation이나 code가 requirement를 어떻게 만족하는지 coverage를 얻으려면 Doxygen의 satisfy alias를 사용합니다.
/**
* @brief Give a semaphore.
*
* This routine gives @a sem, unless the semaphore is already at its maximum
* permitted count.
*
* @note Can be called by ISRs.
*
* @param sem Address of the semaphore.
*
* @satisfy{@req{015}}
*/
__syscall void k_sem_give(struct k_sem *sem);Traceability matrix를 생성하려면 먼저 documentation, 특히 Doxygen XML output을 build해야 합니다.
$ make doxygen그다음 generated Doxygen XML data를 parse해 traceability matrix를 만듭니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.