You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clear and well-structured documentation is essential for code maintainability, readability, and collaboration. Doxygen is a powerful tool that generates documentation from source code comments. This manual aims to establish best practices and guidelines for writing Doxygen comments that enhance the understanding and usability of your codebase.
6
+
7
+
### Core Principles
8
+
9
+
***Clarity:** Write comments that are easy to understand, even for developers who are not familiar with the specific codebase. Avoid jargon, ambiguity, and unnecessary technical details.
10
+
***Conciseness:** Be brief and to the point. Avoid long, rambling sentences and paragraphs. Use clear, concise language to convey essential information.
11
+
***Consistency:** Follow a consistent style and formatting throughout your Doxygen comments. This includes indentation, spacing, tag usage, and the level of detail provided.
12
+
***Completeness:** Ensure your comments cover all the essential aspects of the code element being documented. Include information on the purpose, parameters, return values, possible errors, and any relevant side effects.
13
+
***Accuracy:** Double-check your comments for technical correctness and ensure they accurately reflect the code's behavior and functionality.
14
+
15
+
### Best Practices
16
+
17
+
***Use `/*!< */` for Single-Line Comments:** This is the preferred format for brief descriptions, eliminating the need for the `@brief` tag:
18
+
19
+
```c++
20
+
/*!< Retrieves the current Ethernet WAN interface name. */
21
+
```
22
+
23
+
***Use `/** ... */` for Multi-Line Comments:** For functions with parameters, return values, or more detailed explanations, use multi-line comments to maintain readability:
24
+
25
+
```c++
26
+
/**
27
+
* @brief Initiates a firmware update and factory reset.
28
+
*
29
+
* This function updates the device's firmware (optionally from a specified URL)
30
+
* and then performs a factory reset.
31
+
*
32
+
* ... (more details)
33
+
*/
34
+
```
35
+
36
+
***Focused `@brief` Tags:** Keep the `@brief` description concise and action-oriented, summarizing the core purpose of the function or data structure.
37
+
38
+
***Informative `@param` and `@returns`:**
39
+
***`@param`:** Clearly state the parameter's purpose, expected type, and any constraints or valid values. Use `-` to separate the parameter name from its description.
40
+
***`@returns`:** Provide a general overview of the return value and its meaning.
41
+
42
+
***Detailed `@retval`s:** List each possible return value, followed by a hyphen and a clear explanation.
43
+
44
+
***Use Additional Tags:** Leverage other Doxygen tags like `@note`, `@warning`, `@see`, and `@deprecated` to provide supplementary information, warnings, references, or deprecation notices.
45
+
46
+
***Error Handling (TODO):** Prioritize moving away from generic `RETURN_ERR` values. Instead, define and use an enum for specific error codes to enhance debugging and clarity.
47
+
48
+
### Example: Well-Documented Function
49
+
50
+
```c++
51
+
/**
52
+
* @brief Retrieves the current DOCSIS registration status.
53
+
*
54
+
* This function populates a provided `CMMGMT_CM_DOCSIS_INFO` structure with DOCSIS registration details.
55
+
*
56
+
* @param[out] pinfo - Pointer to a pre-allocated `CMMGMT_CM_DOCSIS_INFO` structure.
Generate a list of acronyms from the source code and specification so that
8
6
9
-
Version format to be defined. Proposal: Major.Minor.Doc
7
+
**Note:** If the list of Acronyms is extensive consider placing in an Appendix Section at the bottom of this document.
10
8
11
-
The version should increment with:
9
+
----
12
10
13
-
* Doc: A change in the documentation. Since the documentation defines sematic operation, it is important as an interface header definition change. It is backward compatible because it does not change the ABI.
11
+
## Example Satement - Acronyms
14
12
15
-
* Minor: A backward compatible change to the API. Defined as no change to the ABI exposed by the library that is used by the client.
13
+
"The following table lists acronyms identified within the `xxx.md` and `xxx.h` files. These acronyms were extracted by carefully reviewing the documents for abbreviations and their corresponding definitions. Note that this list may not be exhaustive, as some acronyms might be used contextually without explicit definition."
16
14
17
-
* Major: A non-backward compatible change to the API.
18
-
19
-
A version history should always be provide to track the evolution of the
20
-
Component interface.
15
+
----
21
16
22
17
# Description
23
18
24
-
A description of services provided by the interface.
19
+
A description of services provided by the interface, including a diagram if possible showing the relationships.
25
20
26
21
Where salient, what it does not need to do.
27
22
23
+
----
24
+
25
+
### Example Diagram
26
+
27
+
This diagram can be tailoured to your needs as required.
These requirements ensure that the component implementing the interface,
@@ -68,16 +78,54 @@ is not allowed to create threads, and a separate thread of execution is
68
78
required, it is likely that this dictates the need for a separate process and
69
79
the proxy information above applies.
70
80
81
+
----
82
+
83
+
## Example Statement - Threading Model
84
+
85
+
Vendors may implement internal threading and event mechanisms to meet their operational requirements. These mechanisms must be designed to ensure thread safety when interacting with HAL interface. Proper cleanup of allocated resources (e.g., memory, file handles, threads) is mandatory when the vendor software terminates or closes its connection to the HAL.
86
+
87
+
----
88
+
71
89
## Process Model
72
90
73
91
Is it a requirement for the component to support multiple instantiation from
74
92
multiple processes, or is there only ever one process that uses the interface?
75
93
94
+
----
95
+
96
+
## Example Statement - Process Model (Must Be Process Safe)
97
+
98
+
All APIs are expected to be called from multiple processes. Due to this concurrent access, vendors must implement protection mechanisms within their API implementations to handle multiple processes calling the same API simultaneously. This is crucial to ensure data integrity, prevent race conditions, and maintain the overall stability and reliability of the system.
99
+
100
+
----
101
+
76
102
## Memory Model
77
103
78
104
If the interface is expected to allocate and return pointers to memory, what
79
105
are the expected rules with respect to ownership, clean up and termination.
80
106
107
+
----
108
+
109
+
### Example Statement - Memory Model - Option 1
110
+
111
+
**Caller Responsibilities:**
112
+
113
+
- Manage memory passed to specific functions as outlined in the API documentation. This includes allocation and deallocation to prevent leaks.
114
+
115
+
**Module Responsibilities:**
116
+
117
+
- Handle and deallocate memory used for its internal operations.
118
+
- Release all internally allocated memory upon closure to prevent leaks.
119
+
120
+
----
121
+
122
+
**Module Responsibilities:**
123
+
124
+
- Modules must allocate and de-allocate memory for their internal operations, ensuring efficient resource management.
125
+
- Modules are required to release all internally allocated memory upon closure to prevent resource leaks.
126
+
- All module implementations and caller code must strictly adhere to these memory management requirements for optimal performance and system stability. Unless otherwise stated specifically in the API documentation.
127
+
- All strings used in this module must be zero-terminated. This ensures that string functions can accurately determine the length of the string and prevents buffer overflows when manipulating strings.
128
+
81
129
## Power Management Requirements
82
130
83
131
Is there a requirement for the component to participate in power management.
@@ -104,18 +152,44 @@ the threading rules?
104
152
If messages are shared, what are responsibilities for managing the memory
105
153
allocation, etc.
106
154
155
+
----
156
+
157
+
### Example Statement - Asynchronous Notification Model
158
+
159
+
This API is called from a single thread context, therefore is must not suspend.
160
+
107
161
## Blocking calls
108
162
109
163
Are any of the exposed methods allowed to block (sleep or make system calls
110
164
that can block)?
111
165
Call out specific methods that are allowed to block.
112
166
How is a blocked call prematurely terminated?
113
167
168
+
169
+
----
170
+
### Example Statement - Blocking calls
171
+
172
+
**Synchronous and Responsive:** All APIs within this module should operate synchronously and complete within a reasonable timeframe based on the complexity of the operation. Specific timeout values or guidelines may be documented for individual API calls.
173
+
174
+
**Timeout Handling:** To ensure resilience in cases of unresponsiveness, implement appropriate timeouts for API calls where failure due to lack of response is a possibility. Refer to the API documentation for recommended timeout values per function.
175
+
176
+
**Non-Blocking Requirement:** Given the single-threaded environment in which these APIs will be called, it is imperative that they do not block or suspend execution of the main thread. Implementations must avoid long-running operations or utilize asynchronous mechanisms where necessary to maintain responsiveness.
177
+
178
+
----
179
+
114
180
## Internal Error Handling
115
181
116
182
If the component detects an internal error (e.g. out of memory) what should it
117
183
do?
118
184
185
+
### Example Statement - Internal Error Hanlding
186
+
187
+
**Synchronous Error Handling:** All APIs must return errors synchronously as a return value. This ensures immediate notification of errors to the caller.
188
+
**Internal Error Reporting:** The HAL is responsible for reporting any internal system errors (e.g., out-of-memory conditions) through the return value.
189
+
**Focus on Logging for Errors:** For system errors, the HAL should prioritize logging the error details for further investigation and resolution.
190
+
191
+
----
192
+
119
193
## Persistence Model
120
194
121
195
Is the sub-system interfaced to by the HAL interface expected to remember any
@@ -139,6 +213,52 @@ purposes?
139
213
If yes, are there any rules (file naming conventions, etc.) that the component
140
214
should abide by?
141
215
216
+
----
217
+
218
+
### Example Statement - Logging and debugging requirements - option 1
219
+
220
+
The component must log all errors and critical informative messages. Use the syslog facility for structured logging and potential remote logging capabilities. These logs are essential for debugging and understanding the system's operation.
221
+
222
+
Guidelines
223
+
224
+
-**Consistency**: Strive for consistent logging practices across all HAL components for better troubleshooting.
225
+
-**Logs:** Store logs in the file /rdklogs/logs/xxxx_hal.log.
226
+
227
+
Log Levels: Use standard Linux log levels as follows:
228
+
229
+
-**FATAL**: System cannot continue.
230
+
-**ERROR**: Error condition preventing a specific operation.
231
+
-**WARNING**: Unusual condition, but not immediately hindering.
232
+
-**NOTICE**: Normal but noteworthy condition.
233
+
-**INFO**: Informational message.
234
+
-**DEBUG**: Low-level debugging information.
235
+
-**TRACE**: Highly detailed tracing information.
236
+
237
+
Message Formatting: Include timestamps, component names, severity levels, and clear messages. Consider a standard format.
238
+
Log Rotation: Implement log rotation (logrotate) to manage log size.
239
+
240
+
----
241
+
242
+
### Example Statement - Loggign and debugging requirements - option 2
243
+
244
+
The component is required to record all errors and critical informative messages to aid in identifying, debugging, and understanding the functional flow of the system. Logging should be implemented using the syslog method, as it provides robust logging capabilities suited for system-level software. The use of `printf` is discouraged unless `syslog` is not available.
245
+
246
+
All HAL components must adhere to a consistent logging process. When logging is necessary, it should be performed into the `xxx_vendor_hal.log` file, which is located in either the `/var/tmp/` or `/rdklogs/logs/` directories.
247
+
248
+
Logs must be categorized according to the following log levels, as defined by the Linux standard logging system, listed here in descending order of severity:
249
+
250
+
-**FATAL**: Critical conditions, typically indicating system crashes or severe failures that require immediate attention.
251
+
-**ERROR**: Non-fatal error conditions that nonetheless significantly impede normal operation.
252
+
-**WARNING**: Potentially harmful situations that do not yet represent errors.
253
+
-**NOTICE**: Important but not error-level events.
254
+
-**INFO**: General informational messages that highlight system operations.
255
+
-**DEBUG**: Detailed information typically useful only when diagnosing problems.
256
+
-**TRACE**: Very fine-grained logging to trace the internal flow of the system.
257
+
258
+
Each log entry should include a timestamp, the log level, and a message describing the event or condition. This standard format will facilitate easier parsing and analysis of log files across different vendors and components.
259
+
260
+
----
261
+
142
262
## Memory and performance requirements
143
263
144
264
Where memory and performance are of concern, Architecture may of imposed
@@ -147,6 +267,21 @@ limits on memory and CPU usage.
147
267
When the component is delivered, is there a requirement to state memory and
148
268
CPU usage statistics for auditing purposes
149
269
270
+
271
+
----
272
+
273
+
### Example Statement - Memory and performance requirements - Option 1
274
+
275
+
The component should be designed for efficiency, minimizing its impact on system resources during normal operation. Resource utilization (e.g., CPU, memory) should be proportional to the specific task being performed and align with any performance expectations documented in the API specifications.
276
+
277
+
### Example Statement - Memory and performance requirements - Option 2
278
+
279
+
**Client Module Responsibility:** The client module using the HAL is responsible for allocating and deallocating memory for any data structures required by the HAL's APIs. This includes structures passed as parameters to HAL functions and any buffers used to receive data from the HAL.
280
+
281
+
**Vendor Implementation Responsibility:** Third-party vendors, when implementing the HAL, may allocate memory internally for their specific operational needs. It is the vendor's sole responsibility to manage and deallocate this internally allocated memory.
282
+
283
+
----
284
+
150
285
## Quality Control
151
286
152
287
Are there any requirements for the use of static code analysis tools:
@@ -156,19 +291,43 @@ e.g. Coverity, Black duck, etc.
156
291
Testing requirements: valgrind, etc. Any specific test to focus on, e.g.
157
292
longevity testing, etc.
158
293
159
-
What specific component tests should be run.
294
+
What specific component tests should be run?
295
+
296
+
----
297
+
298
+
### Example statement - Quality Control
299
+
300
+
To ensure the highest quality and reliability, it is strongly recommended that third-party quality assurance tools like `Coverity`, `Black Duck`, and `Valgrind` be employed to thoroughly analyze the implementation. The goal is to detect and resolve potential issues such as memory leaks, memory corruption, or other defects before deployment.
301
+
302
+
Furthermore, both the HAL wrapper and any third-party software interacting with it must prioritize robust memory management practices. This includes meticulous allocation, deallocation, and error handling to guarantee a stable and leak-free operation.
303
+
304
+
----
160
305
161
306
## Licensing
162
307
163
308
Are there any licensing requirements?
164
309
310
+
### Example Statement - Licensing
311
+
312
+
The implementation is expected to released under the Apache License 2.0.
313
+
314
+
----
315
+
165
316
## Build Requirements
166
317
167
318
Any build requirements, specific tooling, library format, etc.
168
319
169
320
versions of specific support libraries. Ideally this would be a systemwide for
170
321
the RDK.
171
322
323
+
----
324
+
325
+
### Example statement - Build Requirements
326
+
327
+
The source code should be capable of, but not be limited to, building under the Yocto distribution environment. The recipe should deliver a shared library named as `xxxx.so`
328
+
329
+
----
330
+
172
331
## Variability Management
173
332
174
333
How is evolution managed?
@@ -182,6 +341,17 @@ how is that managed?
182
341
Is there an expected approach for managing different interface library
183
342
versions?
184
343
344
+
345
+
----
346
+
347
+
### Example Statement - Variable Management
348
+
349
+
The role of adjusting the interface, guided by versioning, rests solely within architecture requirements. Thereafter, vendors are obliged to align their implementation with a designated version of the interface. As per Service Level Agreement (SLA) terms, they may transition to newer versions based on demand needs.
350
+
351
+
Each API interface will be versioned using [Semantic Versioning 2.0.0](https://semver.org/), the vendor code will comply with a specific version of the interface.
352
+
353
+
----
354
+
185
355
## Platform or Product Customization
186
356
187
357
State whether the HAL component or sub-system it controls, is expected to
@@ -220,17 +390,28 @@ their life cycle and how they are identified.
220
390
Is there an order in which methods are expected to be called?
221
391
For example:
222
392
223
-
1. Initialization/Open
224
-
225
-
2. Configure
226
-
227
-
3. Start
393
+
- Initialization/Open
394
+
- Configure
395
+
- Start
228
396
229
397
Are there specific methods that will only be called when in a specific state.
230
398
Is there a state model?
231
399
232
400
State diagrams, sequence diagram, etc. are always a useful tool to describe
233
401
all the behavioural aspects of the components.
402
+
----
403
+
404
+
### Extended Information- Theory of operation and key concepts
405
+
406
+
**Purpose**: To provide stakeholders with a clear understanding of how the interfaced component(s) will function.
407
+
408
+
**Key Questions to Address:**
409
+
410
+
**Object Lifecycles:** How are objects within the component created, used, and destroyed? Are there unique identifiers for these objects?
411
+
**Method Sequencing:** Is there a specific order in which the component's methods need to be called (e.g., must be initialized before being configured)?
412
+
**State-Dependent Behavior:** Can certain methods only be used when the component is in a particular state? Does a state model govern the component's behavior?
0 commit comments