Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
/docs/demo
/.cache
/src/config.h
cmbuild.sh


2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ project(doxide
cmake_policy(SET CMP0074 NEW) # use <PackageName>_ROOT to look for packages

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

# Available options to control how dependencies are sourced
Expand Down Expand Up @@ -91,6 +92,7 @@ add_executable(doxide
src/JSONCounter.cpp
src/JSONGenerator.cpp
src/MarkdownGenerator.cpp
src/PlainMarkdownGenerator.cpp
src/SourceWatcher.cpp
src/YAMLNode.cpp
src/YAMLParser.cpp
Expand Down
7 changes: 7 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ MkDocs](https://squidfunk.github.io/mkdocs-material/). To start, it is not
necessary to modify any of these.

Add at least `doxide.yaml` to version control, and the other files if you intend to use Material for MkDocs (highly recommended for a quick start---you can always try something else later).

### For small projects
Sometimes you don't want the dependencies of Mkdocs, and just plain Markdown. You can use:
```
doxide init --plain
```
This will skip the creation of the web oriented output (JavaScript, CSS, etc.) and use only Markdown.
7 changes: 7 additions & 0 deletions docs/running.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ To serve the documentation locally, use:
mkdocs serve
```
and point your browser to the URL reported, usually `localhost:8000`.

### For small projects
If you don't want the Mkdocs noise, you can run:
```
doxide gitdoc
```
This will populate the output directory with GitHub webview-ready Markdown. Block quotes are substituted for Mkdocs admonitions, and unsupported icons are replaced with near-identical unicode characters.
58 changes: 39 additions & 19 deletions src/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@
#include "YAMLParser.hpp"
#include "CppParser.hpp"
#include "MarkdownGenerator.hpp"
#include "PlainMarkdownGenerator.hpp"
#include "GcovCounter.hpp"
#include "JSONCounter.hpp"
#include "JSONGenerator.hpp"
#include "SourceWatcher.hpp"

#include <regex>
#include <thread>

/**
* Contents of initial `doxide.yaml` file.
*
*
* @ingroup developer
*/
static const char* init_doxide_yaml =
R""""(title:
R""""(style:
title:
description:
files:
- "*.hpp"
Expand All @@ -26,12 +29,12 @@ R""""(title:

/**
* Contents of initial `mkdocs.yaml` file.
*
*
* @ingroup developer
*/
static const char* init_mkdocs_yaml =
R""""(site_name:
site_description:
site_description:
theme:
name: material
custom_dir: docs/overrides
Expand All @@ -43,7 +46,7 @@ R""""(site_name:
primary: red
accent: red
toggle:
icon: material/brightness-7
icon: material/brightness-7
name: Switch to dark mode

# Palette toggle for dark mode
Expand Down Expand Up @@ -79,7 +82,7 @@ R""""(site_name:

/**
* Contents of initial `docs/javascripts/mathjax.js` file.
*
*
* @ingroup developer
*/
static const char* init_docs_javascripts_mathjax_js =
Expand All @@ -96,14 +99,14 @@ R""""(window.MathJax = {
}
};

document$.subscribe(() => {
document$.subscribe(() => {
MathJax.typesetPromise()
})
)"""";

/**
* Contents of initial `docs/javascripts/tablesort.js` file.
*
*
* @ingroup developer
*/
static const char* init_docs_javascripts_tablesort_js =
Expand All @@ -117,7 +120,7 @@ R""""(document$.subscribe(function() {

/**
* Contents of initial `docs/stylesheets/doxide.css` file.
*
*
* @ingroup developer
*/
static const char* init_docs_stylesheets_doxide_css =
Expand Down Expand Up @@ -183,7 +186,7 @@ R""""(:root {

/**
* Contents of initial `docs/overrides/partials/copyright.html` file.
*
*
* @ingroup developer
*/
static const char* init_docs_overrides_partials_copyright_html =
Expand Down Expand Up @@ -212,26 +215,35 @@ Driver::Driver() :
//
}

void Driver::init() {
void Driver::init(bool plain_md) {
std::string doxide_yaml = init_doxide_yaml;
std::string mkdocs_yaml = init_mkdocs_yaml;

if (plain_md) {
doxide_yaml = std::regex_replace(doxide_yaml, std::regex("style:"),
"style: plain");
} else {
doxide_yaml = std::regex_replace(doxide_yaml, std::regex("style:"),
"style: mkdocs");
}
doxide_yaml = std::regex_replace(doxide_yaml, std::regex("title:"),
"title: " + title);
doxide_yaml = std::regex_replace(doxide_yaml, std::regex("description:"),
"description: " + description);

mkdocs_yaml = std::regex_replace(mkdocs_yaml, std::regex("site_name:"),
"site_name: " + title);
mkdocs_yaml = std::regex_replace(mkdocs_yaml, std::regex("site_description:"),
"site_description: " + description);

write_file_prompt(doxide_yaml, "doxide.yaml");
write_file_prompt(mkdocs_yaml, "mkdocs.yaml");
write_file_prompt(init_docs_javascripts_mathjax_js, "docs/javascripts/mathjax.js");
write_file_prompt(init_docs_javascripts_tablesort_js, "docs/javascripts/tablesort.js");
write_file_prompt(init_docs_stylesheets_doxide_css, "docs/stylesheets/doxide.css");
write_file_prompt(init_docs_overrides_partials_copyright_html, "docs/overrides/partials/copyright.html");
if (!plain_md) {
write_file_prompt(mkdocs_yaml, "mkdocs.yaml");
write_file_prompt(init_docs_javascripts_mathjax_js, "docs/javascripts/mathjax.js");
write_file_prompt(init_docs_javascripts_tablesort_js, "docs/javascripts/tablesort.js");
write_file_prompt(init_docs_stylesheets_doxide_css, "docs/stylesheets/doxide.css");
write_file_prompt(init_docs_overrides_partials_copyright_html, "docs/overrides/partials/copyright.html");
}
}

void Driver::build() {
Expand All @@ -257,7 +269,7 @@ void Driver::watch() {

for (;;){
std::this_thread::sleep_for(std::chrono::milliseconds(2000));

if (config_watcher.changed()){
std::cout << std::endl << "Detected configuration file change." << std::endl;
std::cout << "Rebuilding documentation..." << std::endl;
Expand Down Expand Up @@ -350,6 +362,13 @@ void Driver::config() {
YAMLParser parser;
YAMLNode yaml = parser.parse(config_file);

if (yaml.has("style")) {
if (yaml.isValue("style")) {
style = yaml.value("style");
} else {
warn("'style' must be a value in configuration.");
}
}
if (yaml.has("title")) {
if (yaml.isValue("title")) {
title = yaml.value("title");
Expand Down Expand Up @@ -390,7 +409,7 @@ void Driver::config() {
warn("'defines' must be a mapping in configuration.");
}
}

/* expand file patterns in file list */
filenames.clear();
if (yaml.isSequence("files")) {
Expand All @@ -416,6 +435,7 @@ void Driver::config() {

/* initialize root entity */
groups(yaml, root);
root.style = style;
root.title = title;
root.docs = description;
}
Expand Down
19 changes: 17 additions & 2 deletions src/Driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/**
* Driver for running commands
*
*
* @ingroup developer
*/
class Driver {
Expand All @@ -19,13 +19,18 @@ class Driver {
/**
* Create a new configuration file.
*/
void init();
void init(bool plain);

/**
* Build documentation.
*/
void build();

/**
* Build GetHub webview ready documentation.
*/
void git_build();

/**
* Watch and build documentation on changes.
*/
Expand All @@ -41,6 +46,11 @@ class Driver {
*/
void clean();

/**
* Style.
*/
std::string style;

/**
* Title.
*/
Expand All @@ -61,6 +71,11 @@ class Driver {
*/
std::filesystem::path output;

/**
* Whether to remove Mkdocs noise.
*/
bool plain;

private:
/**
* Read in the configuration file.
Expand Down
25 changes: 15 additions & 10 deletions src/Entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/**
* Entity types.
*
*
* @ingroup developer
*/
enum class EntityType {
Expand All @@ -28,7 +28,7 @@ enum class EntityType {

/**
* Entity in a C++ source file, e.g. variable, function, class, etc.
*
*
* @ingroup developer
*/
struct Entity {
Expand All @@ -45,24 +45,24 @@ struct Entity {

/**
* Add child entity.
*
*
* @param o Child entity.
*
*
* If the child has `ingroup` set, then will search for and add to that
* group instead.
*/
void add(Entity&& o);

/**
* Merge the children of another entity into this one.
*
*
* @param o Other entity.
*/
void merge(Entity&& o);

/**
* Does a file exist of the given name?
*
*
* @param path File path.
*/
bool exists(std::filesystem::path& path) const;
Expand Down Expand Up @@ -167,6 +167,11 @@ struct Entity {
*/
std::string docs;

/**
* Entity style. This is used to generate certain types of Markdown.
*/
std::string style;

/**
* Entity title. This is used for the title of the page.
*/
Expand Down Expand Up @@ -232,19 +237,19 @@ struct Entity {
private:
/**
* Add child entity to a group.
*
*
* @param o Child entity with `ingroup` set.
*
*
* @return True if a group of the given name was found, in which case @p o
* will have been added to it, false otherwise.
*/
bool addToGroup(Entity&& o);

/**
* Add child entity.
*
*
* @param o Child entity.
*
*
* If the child has `ingroup` set, it is ignored.
*/
void addToThis(Entity&& o);
Expand Down
Loading