MkDocs Rails
Easy MkDocs setup for Rails development.
What It Does
Adds Material for MkDocs (or vanilla MkDocs) to your Rails app with one command. Perfect for internal documentation, API docs, and developer guides.
Installation
Add to your Gemfile:
gem "mkdocs_rails", group: :developmentThen run:
bundle install
rails generate mkdocs_rails:installUsage
# First-time setup (creates a local Python venv and installs packages)
bin/docs setup
# Start the MkDocs development server
bin/docs serve
# Visit http://localhost:8000
# Build static docs directly into Rails public/docs
bin/docs publish
# Clean the public/docs directory
bin/docs cleanThe publish command outputs a production-ready static site to public/docs, automatically served by Rails at:
http://localhost:3000/docs/The trailing slash (/) is required for the static docs to display correctly.
Features
- Generator creates complete MkDocs project structure
- Material for MkDocs theme by default (or use
--vanillafor plain MkDocs) - Automatic Python virtual environment management
- Auto-detects and installs plugins from
mkdocs.yml - Simple
bin/docsscript for common tasks
Customization
Using Vanilla MkDocs
rails generate mkdocs_rails:install --vanillaAdding Plugins
Edit docs/mkdocs.yml:
plugins:
- search
- awesome-pagesMost plugins follow the convention mkdocs-{name}-plugin. For custom package names, create docs/.mkdocs-packages:
plugins:
awesome-pages: mkdocs-awesome-pages-plugin
glightbox: mkdocs-glightboxThen run bin/docs setup to install.
Contributing
Bug reports and pull requests are welcome.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am "Added some new feature") - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
License
The gem is available as open source under the terms of the MIT License.