Skip to content

Commit 97ee87a

Browse files
committed
add: Using Codespaces
* Describe how to use Codespaces with the repo. * Add a script that wraps the generation in a single command. Signed-off-by: mr.Shu <[email protected]>
1 parent 3484233 commit 97ee87a

File tree

3 files changed

+83
-4
lines changed

3 files changed

+83
-4
lines changed

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The rules are written in a human readable formatting langue called
2828
[AsciiDoc](https://asciidoctor.org/docs/asciidoc-writers-guide/), which should
2929
make them quite readable and easy to edit, so please feel free to do so!
3030

31-
## That's way too complicated!
31+
## That's way too complicated
3232

3333
We do realize it may look like that. If you do not feel comfortable with
3434
suggesting a change using the process above, feel free to create a new thread
@@ -40,7 +40,6 @@ that your submission contains answers to the following sections:
4040
- **Explain why do you think it should be in the rules**
4141
- **List the relevant section(s) of previous rules (if applicable)**
4242

43-
4443
We can discuss your suggestion there, and if it makes sense someone will
4544
certainly put it into the actual `rules.adoc` document.
4645

@@ -66,8 +65,8 @@ steps:
6665
At the end of this process we end up with a **HTML** and a **PDF** version of
6766
the AsciiDoc file we started with.
6867

69-
This repository is connected to so called [Travis CI](http://travis-ci.org/)
70-
which allows us to automatically build the rules whenever any change/update
68+
This repository is using [GitHub Actions](./github/workflows/) which allows us to
69+
automatically build the rules whenever any change/update
7170
takes place.
7271

7372
If you'd like to try it on your own, it should not be such a big problem,
@@ -80,3 +79,19 @@ thorugh the build process in two easy steps:
8079
Which will make the `rules.adoc` file (in the current working directory --
8180
that's the `$(pwd)` part) go through the build steps above and generate files
8281
`rules.html` and `rules.pdf` as a result.
82+
83+
## Use GitHub Codespaces to edit these files
84+
85+
GitHub now has a nice service called [Codespaces](https://github.com/features/codespaces)
86+
which allows us to spin up a "development environment" without having to
87+
install various dependencies without having to leave the web browser.
88+
89+
Here is a short tutorial on how to edit the rules in Codespaces.
90+
91+
### Spinning up Codespaces and building the rules
92+
93+
1. First, navigate to the top part of the repository.
94+
95+
2. Click on **Code** and then on **Create codespace on master**
96+
97+
![Create Codespace](./images/codespaces.png)

images/codespaces.png

58.7 KB
Loading

scripts/build-rules.bash

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Colors
5+
RED="\033[0;31m"
6+
GREEN="\033[0;32m"
7+
YELLOW="\033[1;33m"
8+
BLUE="\033[0;34m"
9+
RESET="\033[0m"
10+
11+
# Variables
12+
SERVER_PORT=12345
13+
14+
# Functions
15+
function print_error {
16+
echo -e "${RED}[ERROR] $1${RESET}"
17+
}
18+
19+
function print_success {
20+
echo -e "${GREEN}[SUCCESS] $1${RESET}"
21+
}
22+
23+
function print_info {
24+
echo -e "${BLUE}[INFO] $1${RESET}"
25+
}
26+
27+
# Check if the first argument is provided
28+
if [[ $# -lt 1 ]]; then
29+
print_error "No target file specified. Usage: $0 <target-file>"
30+
print_info "The target file is usually 'rules' or 'superteam_rules'."
31+
exit 1
32+
fi
33+
34+
TARGET=$1
35+
36+
# Check if the target file exists
37+
if [[ ! -f "$TARGET.adoc" ]]; then
38+
print_error "Target file '$TARGET.adoc' does not exist."
39+
exit 1
40+
fi
41+
42+
# Check if dependencies are installed
43+
for cmd in docker python; do
44+
if ! command -v "$cmd" &>/dev/null; then
45+
print_error "Dependency '$cmd' is not installed. Please install it and try again."
46+
exit 1
47+
fi
48+
done
49+
50+
# Run Docker containers for processing
51+
print_info "Converting Asciidoc to LaTeX..."
52+
docker run -v "$(pwd)":/documents asciidoctor/docker-asciidoctor .ci/adoc-to-tex.sh "$TARGET"
53+
print_success "Asciidoc conversion complete."
54+
55+
print_info "Converting LaTeX to PDF..."
56+
docker run -v "$(pwd)":/documents mrshu/texlive-dblatex .ci/tex-to-pdf.sh "$TARGET"
57+
print_success "PDF conversion complete."
58+
59+
# Serve the files using Python's HTTP server
60+
echo -e "${YELLOW}See the HTML version at: ${BLUE}http://localhost:$SERVER_PORT/tmp_$TARGET.html${RESET}"
61+
echo -e "${YELLOW}See the PDF version at: ${BLUE}http://localhost:$SERVER_PORT/tmp_$TARGET.pdf${RESET}"
62+
63+
print_info "Starting HTTP server on port $SERVER_PORT..."
64+
python -m http.server "$SERVER_PORT"

0 commit comments

Comments
 (0)