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
How comments are laid out can have a significant effect on readability.
If we're to have 80column headers, then placing documentation comments
before a declaration line - rather than on the end of the same line -
can enable clang format to generate more readable headers without a
great change in the overall line length..
This might use more or less vertical space than the existing version,
since lines aren't off the right hand side. As an example:
```cpp
urLoaderConfigGetInfo(
ur_loader_config_handle_t hLoaderConfig, ///< [in] handle of the loader config object
ur_loader_config_info_t propName, ///< [in] type of the info to retrieve
size_t propSize, ///< [in] the number of bytes pointed to by pPropValue.
void *pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding
///< the info.
///< If propSize is not equal to or greater than the real number of bytes
///< needed to return the info
///< then the ::UR_RESULT_ERROR_INVALID_SIZE error is returned and
///< pPropValue is not used.
size_t *pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName.
);
```
->
```cpp
urLoaderConfigGetInfo(
/// [in] handle of the loader config object
ur_loader_config_handle_t hLoaderConfig,
/// [in] type of the info to retrieve
ur_loader_config_info_t propName,
/// [in] the number of bytes pointed to by pPropValue.
size_t propSize,
/// [out][optional][typename(propName, propSize)] array of bytes holding the
/// info. If propSize is not equal to or greater than the real number of bytes
/// needed to return the info then the ::UR_RESULT_ERROR_INVALID_SIZE error is
/// returned and pPropValue is not used.
void *pPropValue,
/// [out][optional] pointer to the actual size in bytes of the queried propName.
size_t *pPropSizeRet
);
```
The comment and declaration for pPropValue takes fewer lines here, but
the shorter comments occupy more space.
Here is another example, where certain sequences can end up the same
length, but with a slightly more consistent appearance : enumerations
where the enumerator itself is long, and explicit values for the
enumerator declaration:
```cpp
UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER =
7, ///< Enumerator for ::urContextSetExtendedDeleter
```
->
```cpp
/// Enumerator for ::urContextSetExtendedDeleter
UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER = 7,
```
```
The total line length change for those files touched by the generator:
before:
```
12411 include/ur_api.h
1832 include/ur_ddi.h
1564 scripts/templates/helper.py
6818 source/adapters/null/ur_nullddi.cpp
7650 source/loader/layers/tracing/ur_trcddi.cpp
10658 source/loader/layers/validation/ur_valddi.cpp
9173 source/loader/ur_ldrddi.cpp
8706 source/loader/ur_libapi.cpp
7390 source/ur_api.cpp
66202 total
```
After:
```
13051 include/ur_api.h
1832 include/ur_ddi.h
1564 scripts/templates/helper.py
6986 source/adapters/null/ur_nullddi.cpp
7671 source/loader/layers/tracing/ur_trcddi.cpp
10153 source/loader/layers/validation/ur_valddi.cpp
8986 source/loader/ur_ldrddi.cpp
8770 source/loader/ur_libapi.cpp
7637 source/ur_api.cpp
66650 total
```
That's a less than 1% line length increase for generated code, so I
think this is a win.
0 commit comments