Skip to content

Commit

Permalink
Improving mdbook
Browse files Browse the repository at this point in the history
  • Loading branch information
d-krupke committed Apr 29, 2024
1 parent c63a3bb commit b086466
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .mdbook/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ src = "."
title = "CP-SAT Primer - Using and Understanding OR-Tools' CP-SAT"
[output.html]
mathjax-support = true
edit-url-template = "https://github.com/d-krupke/cpsat-primer/edit/main/{path}"
git-repository-url = "https://github.com/d-krupke/cpsat-primer/"
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- This file was generated by the `build.py` script. Do not edit it manually. -->
<!-- 00_intro.md -->
<!-- EDIT THIS PART VIA 00_intro.md -->

# Using and Understanding OR-Tools' CP-SAT: A Primer and Cheat Sheet
Expand Down Expand Up @@ -120,6 +122,8 @@ awaits you in this primer:
---

<!-- This file was generated by the `build.py` script. Do not edit it manually. -->
<!-- 01_installation.md -->
<!-- EDIT THIS PART VIA 01_installation.md -->

## Installation
Expand Down Expand Up @@ -186,6 +190,8 @@ which are likely to be similar. Since we frequently use Gurobi in addition to
CP-SAT, our hardware choices were also influenced by their recommendations.


<!-- This file was generated by the `build.py` script. Do not edit it manually. -->
<!-- 02_example.md -->
<!-- EDIT THIS PART VIA 02_example.md -->

## Example
Expand Down Expand Up @@ -383,6 +389,8 @@ very good at that).

---

<!-- This file was generated by the `build.py` script. Do not edit it manually. -->
<!-- 03_big_picture.md -->
<!-- EDIT THIS PART VIA 03_big_picture.md -->
<a name="section-alternatives"></a>

Expand Down Expand Up @@ -552,6 +560,8 @@ open-source tool.

---

<!-- This file was generated by the `build.py` script. Do not edit it manually. -->
<!-- 04_modelling.md -->
<!--EDIT THIS PART VIA 04_modelling.md -->
## Modelling
<a name="04-modelling"></a>
Expand Down Expand Up @@ -1700,6 +1710,8 @@ If you need more, you can check out the
---


<!-- This file was generated by the `build.py` script. Do not edit it manually. -->
<!-- 05_parameters.md -->
<!-- EDIT THIS PART VIA 05_parameters.md -->

## Parameters
Expand Down Expand Up @@ -2217,6 +2229,8 @@ some conflicts.
---

<!-- This file was generated by the `build.py` script. Do not edit it manually. -->
<!-- 06_coding_patterns.md -->

<!-- EDIT THIS PART VIA 06_coding_patterns.md -->
## Coding Patterns for Optimization Problems
Expand Down Expand Up @@ -2885,6 +2899,8 @@ class KnapsackSolver:

---

<!-- This file was generated by the `build.py` script. Do not edit it manually. -->
<!-- 07_under_the_hood.md -->
<!-- EDIT THIS PART VIA 07_under_the_hood.md -->

## How does it work?
Expand Down Expand Up @@ -3069,6 +3085,8 @@ At times, NP-hard problems inherently pose formidable challenges, leaving us
with no alternative but to seek more manageable modeling approaches instead of
looking for better solvers.

<!-- This file was generated by the `build.py` script. Do not edit it manually. -->
<!-- 08_benchmarking.md -->
<!-- EDIT THIS PART VIA 08_benchmarking.md -->

## Benchmarking your Model
Expand Down Expand Up @@ -3479,6 +3497,8 @@ and nice plots on which we can base our decisions.
> [Algorithm Selection](https://en.wikipedia.org/wiki/Algorithm_selection)
> problem and can be surprisingly complex, too.
<!-- This file was generated by the `build.py` script. Do not edit it manually. -->
<!-- 09_lns.md -->
<!-- EDIT THIS PART VIA 08_lns.md -->

## Using CP-SAT for Bigger Problems with Large Neighborhood Search
Expand Down
9 changes: 9 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
This file is used to build the `README.md` file from all markdown files in the current directory.
It also converts the markdown files to a format that can be used by the `mdbook` tool, which we
use to generate the website.
"""

import os
import re
from pathlib import Path
Expand Down Expand Up @@ -32,8 +38,11 @@ def convert_for_mdbook(content):
# concat them and write them to `README.md`
with open("README.md", "w") as f:
for file in markdown_files:
disclaimer = "<!-- This file was generated by the `build.py` script. Do not edit it manually. -->\n"
with open(file, "r") as current_file:
content = current_file.read()
f.write(disclaimer)
f.write("<!-- " + file + " -->\n")
f.write(content)
f.write("\n\n")
Path("./.mdbook/").mkdir(parents=True, exist_ok=True)
Expand Down

0 comments on commit b086466

Please sign in to comment.