Skip to content

Commit

Permalink
fix(modem): Fixup the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
david-cermak committed Nov 6, 2024
1 parent 3a2acb4 commit fdcc67a
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 49 deletions.
Original file line number Diff line number Diff line change
@@ -1,34 +1,5 @@
#pragma once
//
//#define INT_IN(name) int name
//#ifdef __cplusplus
//#define STRING_IN(name) const std::string& name
//#define STRING_OUT(name) std::string& name
//#define BOOL_IN(name) const bool name
//#define BOOL_OUT(name) bool& name
//#define INT_OUT(name) int& name
//#define INTEGER_LIST_IN(name) const int* name
//#define STRUCT_OUT(struct_name, name) struct_name& name
//#else
//#define STRING_IN(name) const char* name
//#define STRING_OUT(name) char* name
//#define BOOL_IN(name) const bool name
//#define BOOL_OUT(name) bool* name
//#define INT_OUT(name) int* name
//#define INTEGER_LIST_IN(name) const int* name
//#define STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name
//#endif
//
//#define FORWARD_INT_IN(name) name
//#define FORWARD_STRING_IN(name) name
//#define FORWARD_STRING_OUT(name) name
//#define FORWARD_BOOL_IN(name) name
//#define FORWARD_BOOL_OUT(name) name
//#define FORWARD_INT_OUT(name) name
//#define FORWARD_INTEGER_LIST_IN(name) name
//#define FORWARD_STRUCT_OUT(struct_name, name) name

// Utility to count arguments (works for up to two parameters here)
#define ESP_MODEM_GET_MACRO(_0, _1, _2, _3, _4, _5, _6, ESP_MODEM_MACRO_NAME, ...) ESP_MODEM_MACRO_NAME
#define ESP_MODEM_COMMAND_PARAMS(...) ESP_MODEM_GET_MACRO(_0, ##__VA_ARGS__, ESP_MODEM_HELPER6, ESP_MODEM_HELPER5, ESP_MODEM_HELPER4, ESP_MODEM_HELPER3, ESP_MODEM_HELPER2, ESP_MODEM_HELPER1, ESP_MODEM_HELPER0)(PARAM_, ESP_MODEM_NO_COMMA, ESP_MODEM_NO_COMMA, ##__VA_ARGS__)
#define ESP_MODEM_COMMAND_PARAMS_AFTER(...) ESP_MODEM_GET_MACRO(_0, ##__VA_ARGS__, ESP_MODEM_HELPER6, ESP_MODEM_HELPER5, ESP_MODEM_HELPER4, ESP_MODEM_HELPER3, ESP_MODEM_HELPER2, ESP_MODEM_HELPER1, ESP_MODEM_HELPER0)(PARAM_, ESP_MODEM_COMMA, ESP_MODEM_NO_COMMA, ##__VA_ARGS__)
Expand All @@ -45,14 +16,6 @@
#define PARAM_STRUCT_OUT(struct_name, name) struct_name& name
#define PARAM_INT_LIST_IN(name) const int* name
#else
//#define STRING_IN(name) const char* name
//#define STRING_OUT(name) char* name
//#define BOOL_IN(name) const bool name
//#define BOOL_OUT(name) bool* name
//#define INT_OUT(name) int* name
//#define INTEGER_LIST_IN(name) const int* name
//#define STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name

#define PARAM_STR_OUT(name) char* name
#define PARAM_STR_IN(name) const char* name
#define PARAM_INT_OUT(name) int* name
Expand All @@ -61,8 +24,8 @@
#define PARAM_BOOL_OUT(name) bool* name
#define PARAM_STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name
#define PARAM_INT_LIST_IN(name) const int* name

#endif

#define FORWARD_STR_OUT(name) name
#define FORWARD_STR_IN(name) name
#define FORWARD_INT_OUT(name) name
Expand Down
4 changes: 3 additions & 1 deletion components/esp_modem/scripts/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ for file in "${files[@]}"; do
echo "Processing $in_file"

# Process the header and includes -- just paste the content (without expanding)
sed -n '1,/ESP-MODEM command module starts here/p' "$in_file" > "$out_file"
sed -n '1,/ESP-MODEM command module starts here/{/ESP-MODEM command module starts here/d;p}' "$in_file" > "$out_file"

# Determine whether to use clang or clang++ based on file extension
if [[ $file == *.cpp || $file == *.hpp ]]; then
compiler="clang++ -E -P -CC -xc++"
elif [[ $file == *.rst ]]; then
compiler="clang -E -P -xc"
else
compiler="clang -E -P -CC -xc"
fi
Expand Down
4 changes: 2 additions & 2 deletions docs/esp_modem/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,8 @@ INPUT = \
$(PROJECT_PATH)/../components/esp_modem/include/cxx_include/esp_modem_terminal.hpp \
$(PROJECT_PATH)/../components/esp_modem/include/cxx_include/esp_modem_cmux.hpp \
$(PROJECT_PATH)/../components/esp_modem/include/cxx_include/esp_modem_dce.hpp \
$(PROJECT_PATH)/../docs/esp_modem/en/esp_modem_api_commands.h \
$(PROJECT_PATH)/../docs/esp_modem/en/esp_modem_dce.hpp
$(PROJECT_PATH)/../docs/esp_modem/command/dce.h \
$(PROJECT_PATH)/../docs/esp_modem/command/dce.hpp


# The last two are generated
Expand Down
2 changes: 1 addition & 1 deletion docs/esp_modem/en/cxx_api_docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Mode switching commands
Modem commands
--------------

.. include:: cxx_api_links.rst
.. include:: ../command/dce.rst

.. _cpp_destroy:

Expand Down
6 changes: 6 additions & 0 deletions docs/esp_modem/generate/dce.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

// --- ESP-MODEM command module starts here ---
#include "esp_modem_command_declare_helper.inc"
#define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, ...) return_type esp_modem_ ## name (ESP_MODEM_COMMAND_PARAMS(__VA_ARGS__));

#include "esp_modem_command_declare.inc"
16 changes: 16 additions & 0 deletions docs/esp_modem/generate/dce.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

// --- ESP-MODEM command module starts here ---
class esp_modem::DCE : public DCE_T<GenericModule> {
public:
using DCE_T<GenericModule>::DCE_T;

#include "esp_modem_command_declare_helper.inc"
#define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, ...) \
return_type name(ESP_MODEM_COMMAND_PARAMS(__VA_ARGS__));


#include "esp_modem_command_declare.inc"

#undef ESP_MODEM_DECLARE_DCE_COMMAND

};
6 changes: 6 additions & 0 deletions docs/esp_modem/generate/dce.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

// --- ESP-MODEM command module starts here ---

#define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, ...) - :cpp:func:`esp_modem::DCE::name`

#include "esp_modem_command_declare.inc"
13 changes: 6 additions & 7 deletions docs/esp_modem/generate_docs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
# Cleanup the generated html
rm -rf html docs

# Generate C++ API header of the DCE
cat ../../components/esp_modem/include/generate/esp_modem_command_declare.inc | clang++ -E -P -CC -xc++ -I../../components/esp_modem/include -DGENERATE_DOCS - | sed -n '1,/DCE command documentation/!p' > en/esp_modem_dce.hpp
pushd `pwd`

# Generate C API header of the modem_api.h
cat ../../components/esp_modem/include/generate/esp_modem_command_declare.inc | clang -E -P -CC -xc -I../../components/esp_modem/include -DGENERATE_DOCS - | sed -n '1,/DCE command documentation/!p' > en/esp_modem_api_commands.h
cd ../../components/esp_modem/scripts
./generate.sh ../../docs/esp_modem/generate/dce.rst
./generate.sh ../../docs/esp_modem/generate/dce.hpp
./generate.sh ../../docs/esp_modem/generate/dce.h


# RST with links to C++ API
cat ../../components/esp_modem/include/generate/esp_modem_command_declare.inc | clang -E -P -xc -I../../components/esp_modem/include -DGENERATE_DOCS -DGENERATE_RST_LINKS - | sed 's/NL/\n/g' > en/cxx_api_links.rst
popd

build-docs --target esp32 --language en

Expand Down

0 comments on commit fdcc67a

Please sign in to comment.