diff --git a/.github/workflows/doxygen.yml b/.github/workflows/doxygen.yml new file mode 100644 index 00000000..c43f92a5 --- /dev/null +++ b/.github/workflows/doxygen.yml @@ -0,0 +1,30 @@ +name: deploy-doxygen + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Doxygen + run: | + sudo apt-get update + sudo apt-get install -y doxygen graphviz + + - name: Generate Documentation + run: doxygen ./Doxyfile + + - name: Deploying to Gh-pages + uses: jinxto/doxygen-env-setup@v1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index c12126e8..036ebfeb 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ CMakeFiles *.app /cmake-build-debug-coverage/ /cmake-build-release-coverage/ + +#Generated documentation +doc/ diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 00000000..c55489e5 --- /dev/null +++ b/Doxyfile @@ -0,0 +1,335 @@ +DOXYFILE_ENCODING = UTF-8 +PROJECT_NAME = "MCPP" +PROJECT_NUMBER = +PROJECT_BRIEF = +PROJECT_LOGO = +OUTPUT_DIRECTORY = ./doc/ +CREATE_SUBDIRS = NO +ALLOW_UNICODE_NAMES = NO +OUTPUT_LANGUAGE = English +OUTPUT_TEXT_DIRECTION = None +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +JAVADOC_BANNER = NO +QT_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +PYTHON_DOCSTRING = YES +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 4 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +OPTIMIZE_FOR_FORTRAN = NO +OPTIMIZE_OUTPUT_VHDL = NO +OPTIMIZE_OUTPUT_SLICE = NO +EXTENSION_MAPPING = +MARKDOWN_SUPPORT = YES +TOC_INCLUDE_HEADINGS = 5 +AUTOLINK_SUPPORT = YES +BUILTIN_STL_SUPPORT = NO +CPP_CLI_SUPPORT = NO +SIP_SUPPORT = NO +IDL_PROPERTY_SUPPORT = YES +DISTRIBUTE_GROUP_DOC = NO +GROUP_NESTED_COMPOUNDS = NO +SUBGROUPING = YES +INLINE_GROUPED_CLASSES = NO +INLINE_SIMPLE_STRUCTS = NO +TYPEDEF_HIDES_STRUCT = NO +LOOKUP_CACHE_SIZE = 0 +NUM_PROC_THREADS = 1 +EXTRACT_ALL = YES +EXTRACT_PRIVATE = NO +EXTRACT_PRIV_VIRTUAL = NO +EXTRACT_PACKAGE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +EXTRACT_ANON_NSPACES = NO +RESOLVE_UNNAMED_PARAMS = YES +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +HIDE_COMPOUND_REFERENCE= NO +SHOW_INCLUDE_FILES = YES +SHOW_GROUPED_MEMB_INC = NO +FORCE_LOCAL_INCLUDES = NO +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_MEMBERS_CTORS_1ST = NO +SORT_GROUP_NAMES = NO +SORT_BY_SCOPE_NAME = NO +STRICT_PROTO_MATCHING = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_FILES = YES +SHOW_NAMESPACES = YES +FILE_VERSION_FILTER = +LAYOUT_FILE = +CITE_BIB_FILES = +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_AS_ERROR = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +INPUT = ./include/mcpp +INPUT_ENCODING = UTF-8 +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f95 \ + *.f03 \ + *.f08 \ + *.f18 \ + *.f \ + *.for \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf \ + *.ice +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXCLUDE_SYMBOLS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +FILTER_SOURCE_PATTERNS = +USE_MDFILE_AS_MAINPAGE = +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = NO +REFERENCES_RELATION = NO +REFERENCES_LINK_SOURCE = YES +SOURCE_TOOLTIPS = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +CLANG_ASSISTED_PARSING = NO +CLANG_ADD_INC_PATHS = YES +CLANG_OPTIONS = +CLANG_DATABASE_PATH = +ALPHABETICAL_INDEX = YES +IGNORE_PREFIX = +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_EXTRA_STYLESHEET = +HTML_EXTRA_FILES = +HTML_COLORSTYLE_HUE = 220 +HTML_COLORSTYLE_SAT = 100 +HTML_COLORSTYLE_GAMMA = 80 +HTML_TIMESTAMP = NO +HTML_DYNAMIC_MENUS = YES +HTML_DYNAMIC_SECTIONS = NO +HTML_INDEX_NUM_ENTRIES = 100 +GENERATE_DOCSET = NO +DOCSET_FEEDNAME = "Doxygen generated docs" +DOCSET_BUNDLE_ID = org.doxygen.Project +DOCSET_PUBLISHER_ID = org.doxygen.Publisher +DOCSET_PUBLISHER_NAME = Publisher +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +CHM_INDEX_ENCODING = +BINARY_TOC = NO +TOC_EXPAND = NO +GENERATE_QHP = NO +QCH_FILE = +QHP_NAMESPACE = org.doxygen.Project +QHP_VIRTUAL_FOLDER = doc +QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = +QHG_LOCATION = +GENERATE_ECLIPSEHELP = NO +ECLIPSE_DOC_ID = org.doxygen.Project +DISABLE_INDEX = NO +GENERATE_TREEVIEW = NO +ENUM_VALUES_PER_LINE = 4 +TREEVIEW_WIDTH = 250 +EXT_LINKS_IN_WINDOW = NO +HTML_FORMULA_FORMAT = png +FORMULA_FONTSIZE = 10 +FORMULA_TRANSPARENT = YES +FORMULA_MACROFILE = +USE_MATHJAX = NO +MATHJAX_FORMAT = HTML-CSS +MATHJAX_RELPATH = https://cdn.jsdelivr.net/npm/mathjax@2 +MATHJAX_EXTENSIONS = +MATHJAX_CODEFILE = +SEARCHENGINE = YES +SERVER_BASED_SEARCH = NO +EXTERNAL_SEARCH = NO +SEARCHENGINE_URL = +SEARCHDATA_FILE = searchdata.xml +EXTERNAL_SEARCH_ID = +EXTRA_SEARCH_MAPPINGS = +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = +MAKEINDEX_CMD_NAME = makeindex +LATEX_MAKEINDEX_CMD = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4 +EXTRA_PACKAGES = +LATEX_HEADER = +LATEX_FOOTER = +LATEX_EXTRA_STYLESHEET = +LATEX_EXTRA_FILES = +PDF_HYPERLINKS = YES +USE_PDFLATEX = YES +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +LATEX_SOURCE_CODE = NO +LATEX_BIB_STYLE = plain +LATEX_TIMESTAMP = NO +LATEX_EMOJI_DIRECTORY = +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +RTF_SOURCE_CODE = NO +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_SUBDIR = +MAN_LINKS = NO +GENERATE_XML = NO +XML_OUTPUT = xml +XML_PROGRAMLISTING = YES +XML_NS_MEMB_FILE_SCOPE = NO +GENERATE_DOCBOOK = YES +DOCBOOK_OUTPUT = docbook +DOCBOOK_PROGRAMLISTING = NO +GENERATE_AUTOGEN_DEF = NO +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = DOXYGEN_LOGO +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +EXTERNAL_PAGES = YES +CLASS_DIAGRAMS = YES +DIA_PATH = +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = YES +DOT_NUM_THREADS = 0 +DOT_FONTNAME = Helvetica +DOT_FONTSIZE = 10 +DOT_FONTPATH = +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +UML_LIMIT_NUM_FIELDS = 10 +DOT_UML_DETAILS = NO +DOT_WRAP_THRESHOLD = 17 +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +CALLER_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +INTERACTIVE_SVG = NO +DOT_PATH = +DOTFILE_DIRS = +MSCFILE_DIRS = +DIAFILE_DIRS = +PLANTUML_JAR_PATH = +PLANTUML_CFG_FILE = +PLANTUML_INCLUDE_PATH = +DOT_GRAPH_MAX_NODES = 50 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES diff --git a/include/mcpp/block.h b/include/mcpp/block.h index 8ed27738..1e3ac36b 100644 --- a/include/mcpp/block.h +++ b/include/mcpp/block.h @@ -2,6 +2,10 @@ #include +/** + * @file + * @brief BlockType class + */ namespace mcpp { class BlockType { public: @@ -11,18 +15,45 @@ class BlockType { constexpr BlockType(int id = 0, int modifier = 0) : id(id), mod(modifier){}; /** + * @brief Equality comparison operator. + * * Watch out as this also compares the BlockType.mod element of the block, * so some equalities may behave in unexpected ways e.g. rotated stairs + * + * @param other The BlockType to compare with the current instance. + * + * @return True if the two BlockType instances are not equal, false + * otherwise. */ bool operator==(const BlockType& other) const; + /** + * @brief Inequality comparison operator. + * + * Watch out as this also compares the BlockType.mod element of the block, + * so some equalities may behave in unexpected ways e.g. rotated stairs + * + * @param other The BlockType to compare with the current instance. + * @return True if the two BlockType instances are not equal, false + * otherwise. + */ bool operator!=(const BlockType& other) const; + /** + * @brief Stream insertion operator for outputting the BlockType to an + * output stream. + * + * @param out The output stream to write to. + * @param block The BlockType instance to output. + * @return A reference to the output stream after the block information has + * been inserted. + */ friend std::ostream& operator<<(std::ostream& out, const BlockType& block); /** * Returns a new BlockType with the same id and specified modifier, useful * for rotations etc. + * * @param modifier New modifier for the BlockType * @return New BlockType object with the specified modifier */ @@ -32,6 +63,7 @@ class BlockType { // Using script to extract ids from https://minecraft-ids.grahamedgecombe.com/ /** + * @struct Blocks * Struct of static block objects that allows for a "search" of sorts, callable * using Blocks::TYPE after importing */ diff --git a/include/mcpp/connection.h b/include/mcpp/connection.h index 56bd1d2e..d332b4f2 100644 --- a/include/mcpp/connection.h +++ b/include/mcpp/connection.h @@ -5,6 +5,10 @@ #define FAIL_RESPONSE "Fail" +/** @file + * @brief SocketConnection class. + * + */ namespace mcpp { class SocketConnection { private: @@ -22,6 +26,7 @@ class SocketConnection { * Takes in parameters supporting std::stringstream conversion and a string * prefix and transforms them into format "prefix(arg1,arg2,arg3)\n" (e.g. * "chat.post(test)\n") and sends command to the server. + * * @tparam Types * @param prefix * @param args @@ -44,6 +49,7 @@ class SocketConnection { /** * Sends via sendCommand() and returns the result from endpoint + * * @tparam T * @tparam Types * @param prefix diff --git a/include/mcpp/mcpp.h b/include/mcpp/mcpp.h index 9dd42472..6cb1085e 100644 --- a/include/mcpp/mcpp.h +++ b/include/mcpp/mcpp.h @@ -7,22 +7,53 @@ #include #include +/** @file + * @brief MinecraftConnection class. + * + */ + +/** + * @brief Namespace containing all the the mcpp library classes. + * + * The mcpp namespace includes classes and functions designed to facilitate + * interaction with the Minecraft world through various server commands + * and data manipulations. + */ namespace mcpp { class MinecraftConnection { private: + /// Handle to the socket connection. std::unique_ptr conn; + /** + * @brief Helper function to convert flat block array to 3D. + * + * @param loc1 The first coordinate. + * @param loc2 The second coordinate. + * @param inVector The input flat block array. + * @return A 3D vector representing the blocks. + */ static std::vector>> unflattenBlocksArray(const Coordinate& loc1, const Coordinate& loc2, const std::vector& inVector); + /** + * @brief Helper function to convert flat height array to 2D. + * + * @param loc1 The first coordinate. + * @param loc2 The second coordinate. + * @param inVector The input flat height array. + * @return A 2D vector representing the heights. + */ static std::vector> unflattenHeightsArray(const Coordinate& loc1, const Coordinate& loc2, const std::vector& inVector); public: /** - * Represents the main endpoint for interaction with the minecraft world. + * @brief Represents the main endpoint for interaction with the minecraft + * world. + * * @param address String address in IPV4 format, defaults to "localhost" * @param port Integer port to run on, defaults to 4711 as that is the port * for ELCI @@ -31,55 +62,66 @@ class MinecraftConnection { int port = 4711); /** - * Sends a message to the in-game chat, does not require a joined player + * @brief Sends a message to the in-game chat, does not require a joined + * player + * * @param message */ void postToChat(const std::string& message); /** - * Performs an in-game minecraft command. Players have to exist on the - * server and should be server operators (default with ELCI) + * @brief Performs an in-game minecraft command. Players have to exist on + * the server and should be server operators (default with ELCI) + * * @param command Command string in the in-game format (e.g. "time set day") */ void doCommand(const std::string& command); /** - * Sets player pos (block pos of lower half of playermodel) to specified - * Coordinate + * @brief Sets player pos (block pos of lower half of playermodel) to + * specified Coordinate + * * @param pos Coordinate to set */ void setPlayerPosition(const Coordinate& pos); /** - * Returns a coordinate representing player position (block pos of lower - * half of playermodel) + * @brief Returns a coordinate representing player position (block pos of + * lower half of playermodel) + * * @return Coordinate of location */ Coordinate getPlayerPosition(); /** - * Sets player position to be one above specified tile (i.e. tile = block - * player is standing on) + * @brief Sets player position to be one above specified tile (i.e. tile = + * block player is standing on) + * * @param tile Coordinate to set */ void setPlayerTilePosition(const Coordinate& tile); /** - * Returns the coordinate location of the block the player is standing on + * @brief Returns the coordinate location of the block the player is + * standing on + * * @return Coordinate of location */ Coordinate getPlayerTilePosition(); /** - * Sets block at Coordinate loc to the BlockType specified by blockType + * @brief Sets block at Coordinate loc to the BlockType specified by + * blockType + * * @param loc * @param blockType */ void setBlock(const Coordinate& loc, const BlockType& blockType); /** - * Sets a cuboid of blocks to the specified BlockType blockType, with the - * corners of the cuboid provided by the Coordinate loc1 and loc2 + * @brief Sets a cuboid of blocks to the specified BlockType blockType, with + * the corners of the cuboid provided by the Coordinate loc1 and loc2 + * * @param loc1 * @param loc2 * @param blockType @@ -88,15 +130,18 @@ class MinecraftConnection { const BlockType& blockType); /** - * Returns BlockType object from the specified Coordinate loc with modifier + * @brief Returns BlockType object from the specified Coordinate loc with + * modifier + * * @param loc * @return BlockType of the requested block */ BlockType getBlock(const Coordinate& loc); /** - * Returns a 3D vector of the BlockTypes of the requested cuboid with + * @brief Returns a 3D vector of the BlockTypes of the requested cuboid with * modifiers + * * @param loc1 1st corner of the cuboid * @param loc2 2nd corner of the cuboid * @return 3D vector of BlockType in the specified cuboid. @@ -105,8 +150,12 @@ class MinecraftConnection { getBlocks(const Coordinate& loc1, const Coordinate& loc2); /** - * IMPORTANT: DO NOT USE FOR LARGE AREAS, IT WILL BE VERY SLOW + * @brief Returns the height of the specific provided x and y coordinate + * + * ***IMPORTANT:*** + * DO NOT USE FOR LARGE AREAS, IT WILL BE VERY SLOW * USE getHeights() INSTEAD + * * Gets the y-value of the highest non-air block at the specified (x, z) * coordinate. * @param x @@ -116,8 +165,11 @@ class MinecraftConnection { int getHeight(int x, int z); /** - * Provides a scaled option of the getHeight call to allow for considerable - * performance gains. USE THIS instead of getHeight in a for loop. + * @brief Provides a scaled option of the getHeight call to allow for + * considerable performance gains. + * + * \par USE THIS instead of getHeight in a for loop. + * * @param loc1 * @param loc2 * @return Returns a vector of integers representing the 2D area of heights. diff --git a/include/mcpp/util.h b/include/mcpp/util.h index c25ba954..7b0225ae 100644 --- a/include/mcpp/util.h +++ b/include/mcpp/util.h @@ -2,6 +2,10 @@ #include +/** @file + * @brief Coordinate class. + * + */ namespace mcpp { /** * Represented using integers since sub-unit coordinates are not of particular @@ -9,20 +13,72 @@ namespace mcpp { */ class Coordinate { public: + /** + * @brief Constructs a Coordinate object with integer values. + * + * @param x The x-coordinate. Default is 0. + * @param y The y-coordinate. Default is 0. + * @param z The z-coordinate. Default is 0. + */ explicit Coordinate(int x = 0, int y = 0, int z = 0); + /** + * @brief Constructs a Coordinate object with double values. + * + * @param x The x-coordinate as a double. + * @param y The y-coordinate as a double. + * @param z The z-coordinate as a double. + */ Coordinate(double x, double y, double z); + /** + * @brief Adds two Coordinate objects. + * + * @param obj The Coordinate object to add. + * @return A new Coordinate object representing the sum of the two + * coordinates. + */ Coordinate operator+(const Coordinate& obj) const; + /** + * @brief Checks if two Coordinate objects are equal. + * + * @param obj The Coordinate object to compare with. + * @return True if the coordinates are equal, false otherwise. + */ bool operator==(const Coordinate& obj) const; + /** + * @brief Checks if two Coordinate objects are not equal. + * + * @param obj The Coordinate object to compare with. + * @return True if the coordinates are not equal, false otherwise. + */ bool operator!=(const Coordinate& obj) const; + /** + * @brief Subtracts one Coordinate object from another. + * + * @param obj The Coordinate object to subtract. + * @return A new Coordinate object representing the difference between the + * two coordinates. + */ Coordinate operator-(const Coordinate& obj) const; + /** + * @brief Creates a copy of the Coordinate object. + * + * @return A new Coordinate object that is a copy of the current object. + */ [[nodiscard]] Coordinate clone() const; + /** + * @brief Outputs the Coordinate object to an ostream. + * + * @param out The output stream. + * @param coord The Coordinate object to output. + * @return The output stream with the Coordinate object's values. + */ friend std::ostream& operator<<(std::ostream& out, const Coordinate& coord); int x;