Skip to content

Feature: Plain Markdown generator.#88

Open
BroDudeGuyMan wants to merge 7 commits intolawmurray:mainfrom
BroDudeGuyMan:feature-plain-md-generator
Open

Feature: Plain Markdown generator.#88
BroDudeGuyMan wants to merge 7 commits intolawmurray:mainfrom
BroDudeGuyMan:feature-plain-md-generator

Conversation

@BroDudeGuyMan
Copy link
Copy Markdown

@BroDudeGuyMan BroDudeGuyMan commented Mar 3, 2026

Problem

Doxide currently only outputs Markdown that is not compatible with GitHub webview, and other Markdown viewers. This is okay for larger projects, but small personal repositories often rely on GitHub webview for source documentation.

Fix

New Generator

I have added a new class called PlainMarkdownGenerator that replaces all Mkdoc-specific Markdown with standard, fully supported syntax. Icons have also been replaced with near-identical Unicode characters.
Use the new generator with: doxide gitdoc

Init options

There is a new option for the init sub-command:

doxide init --plain

This will create doxide.yaml as normal, as well as the output directory, but will skip creating mkdocs.yaml and the web content directories. This leaves only Markdown, with no other dependencies.

How this helps

Now Doxide can be used as both a documentation hosting tool, and a local documentation manager. All without the hassle of manually editing files and removing directories.

Changes:

  • Added src/PlainMarkdownGenerator.hpp
  • Added src/PlainMakrdownGenerator.cpp
  • Added bool Driver::plain
  • Edited Driver::init() to Driver::init(bool plain_md)
  • Edited CMakeLists.txt to add set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  • Added cmbuild.sh to simplify the build process with a dedicated output directory.
  • Added documentation to docs/getting-started.md and docs/running.md

BroDudeGuyMan and others added 4 commits March 3, 2026 00:44
…kdownGenerator.hpp and .cpp. Added new subcommand 'gitdoc' to use the PlainMarkdownGenerator. Added Driver::git_build() to utilize PlainMarkdownGenerator functions instead of MarkdownGenerator.
…rks with `gitdoc` command to have the output directory contain only plain Markdown
Corrected the spelling of 'unsupported' in the documentation.
Copy link
Copy Markdown
Author

@BroDudeGuyMan BroDudeGuyMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cmbuild.sh script is not a dependency and can be removed from the repo. It's simply a helpful script to clean the build dir, configure CMake, and build the project.

Copy link
Copy Markdown
Owner

@lawmurray lawmurray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this @BroDudeGuyMan. I've reviewed the code.

The major issue is that you have copied all of MarkdownGenerator.cpp to PlainMarkdownGenerator.cpp before making your changes in there, which means there is now a lot of duplicated code. That creates a maintenance headache for future: any fixes to that code will need to happen in both files in future. So we can't do that.

Can you instead integrate your changes into MarkdownGenerator.cpp? Similar to what you have done in Driver.cpp, were you just use a few if (plain_md) conditionals to act differently. There are only 10-20 lines that you have had to change in the Markdown generator, so this is the best way.

If you can do that, I can review again.

@lawmurray
Copy link
Copy Markdown
Owner

The cmbuild.sh script is not a dependency and can be removed from the repo. It's simply a helpful script to clean the build dir, configure CMake, and build the project.

Let's remove this file too. Everyone has their own workflows, and they can make such a script themselves if that's how they prefer to work.

@BroDudeGuyMan
Copy link
Copy Markdown
Author

You got it @lawmurray. I can get that done today.

@BroDudeGuyMan
Copy link
Copy Markdown
Author

BroDudeGuyMan commented Mar 11, 2026

@lawmurray I've made the changes. Now, when using init, a style: field is added to the doxide.yaml file. This is referenced in the generator to make the proper adjustments.

Comment thread docs/running.md
### For small projects
If you don't want the Mkdocs noise, you can run:
```
doxide gitdoc
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any gitdoc command implemented. Besides, a separate command is not the preferred approach, so this can be removed.

Comment thread docs/getting-started.md

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
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to document this here, as it's mean to be a "quick start" section.

Comment thread src/doxide.cpp
callback([&]() { driver.init(); });
auto init_cmd = app.add_subcommand("init",
"Initialize configuration files.");
init_cmd->add_flag("--plain",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll elaborate on the discussion page, but I think we should just add a --style command-line option that takes values plain and mkdocs-material. Then doxide init --style plain can do what you want, and doxide build --style plain or putting style: plain in doxide.yaml can do what you want.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense.

Comment thread src/Driver.cpp
#include "YAMLParser.hpp"
#include "CppParser.hpp"
#include "MarkdownGenerator.hpp"
#include "PlainMarkdownGenerator.hpp"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove.

Comment thread src/Driver.cpp
*/
static const char* init_doxide_yaml =
R""""(title:
R""""(style:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the order title, description, style, files. This is a user-editable file, and having style first may confuse.

Comment thread src/Driver.cpp
}

void Driver::init() {
void Driver::init(bool plain_md) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the need to have the bool plain_md parameter. Why not just check the style member variable?

Comment thread src/Driver.cpp
"style: plain");
} else {
doxide_yaml = std::regex_replace(doxide_yaml, std::regex("style:"),
"style: mkdocs");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use mkdocs-material, it's more precise.

Comment thread src/Driver.hpp
* Create a new configuration file.
*/
void init();
void init(bool plain);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, not seeing the need for this parameter, I think there are better ways.

Comment thread src/Driver.hpp
/**
* Build GetHub webview ready documentation.
*/
void git_build();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be a command, let's just use a --style plain command-line option.

Comment thread src/Driver.hpp
/**
* Whether to remove Mkdocs noise.
*/
bool plain;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems redundant with having the style member set to plain? If so, let's remove it, and just use the style member.

Comment thread src/Entity.hpp
/**
* Entity style. This is used to generate certain types of Markdown.
*/
std::string style;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that every entity has its own style attribute, which will slow things down considerably and is unnecessary. Only Driver and MarkdownGenerator should need to know the style.

Comment thread src/MarkdownGenerator.cpp
std::string filename; // file name for this entity
std::string childdir; // directory name for children, relative to filename
if (entity.type == EntityType::ROOT) {
style = entity.style;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, add style to Driver and MarkdownGenerator, but not each Entity.

Comment thread src/MarkdownGenerator.cpp
out << "(" << childdir << sanitize(child->name) << "/index.md)" << std::endl;
out << ": " << line(brief(*child)) << std::endl;
out << std::endl;
if (style == "plain") {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do a string comparison each time, as these are tight inner loops, and doing so will harm performance considerably. Instead, do the comparison once, and store the result in a bool.

Comment thread src/MarkdownGenerator.cpp
out << std::endl;
out << "!!! macro \"" << htmlize(line(child->decl)) << '"' << std::endl;
if (style == "plain") {
out << "> #**Macro**" << std::endl << "> " << htmlize(line(child->decl)) << std::endl;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This unicode character is broken for me. Perhaps it's not in all fonts. Is there an alternative?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this shouldn't exist any longer.

Comment thread .gitignore
/docs/demo
/.cache
/src/config.h
cmbuild.sh
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer exists.

Comment thread CMakeLists.txt
cmake_policy(SET CMP0074 NEW) # use <PackageName>_ROOT to look for packages

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what this does?

Comment thread CMakeLists.txt
src/JSONCounter.cpp
src/JSONGenerator.cpp
src/MarkdownGenerator.cpp
src/PlainMarkdownGenerator.cpp
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete.

@lawmurray
Copy link
Copy Markdown
Owner

Thanks for the update here @BroDudeGuyMan. I've reviewed and left some comments throughout.

What I'd suggest is that we just add a --style command-line option. It can work the same way as --title and --description already do, so:

  1. doxide init --style plain would set style: plain in doxide.yaml, and not generate the extra JavaScript and CSS files that are meant for Material for MkDocs.
  2. style: plain in doxide.yaml, possibly overridden with doxide build --style plain on the command line, would generate the simpler Markdown that you've prepared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants