Skip to content

Commit c478f36

Browse files
committed
Fix export CLI and add HTML documentation for GitHub Pages
- Fix --output flag not being respected (convert relative to absolute path) - Remove .gitignore from export output folder - Skip .git directory during export copy - Update HTML Export requirement and test for .git exclusion - Add generated HTML documentation for GitHub Pages
1 parent 9819251 commit c478f36

File tree

97 files changed

+58737
-20
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+58737
-20
lines changed

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
tmpspec
22
tmpdoc
33

4-
# Generated files in html directory (but keep directory structure)
5-
html/**/*
6-
!html/**/.gitkeep
7-
84
# Rust-specific ignores
95
/target/
106
**/*.rs.bk

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ members = [
66
resolver = "2"
77

88
[workspace.package]
9-
version = "0.8.0"
9+
version = "0.8.1"
1010
edition = "2021"
1111
rust-version = "1.86"
1212
license = "Apache-2.0"

cli/src/cli.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,12 @@ pub fn handle_command(
846846
},
847847
Some(Commands::Export { output }) => {
848848
info!("Exporting model to HTML folder: {}", &output);
849-
let output_path = PathBuf::from(&output);
849+
// Convert to absolute path before export (cwd changes during export)
850+
let output_path = if PathBuf::from(&output).is_absolute() {
851+
PathBuf::from(&output)
852+
} else {
853+
current_dir.join(&output)
854+
};
850855
let git_root = git_commands::get_git_root_dir()?;
851856
export::export_model_with_artifacts(
852857
&model_manager.graph_registry,

core/src/export.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::fs;
33
use std::path::{Path, PathBuf};
44
use log::{debug,warn,info};
55
use crate::git_commands;
6-
use std::io::Write;
76

87
use crate::error::ReqvireError;
98
use crate::html_export;
@@ -18,14 +17,6 @@ fn prepare_output_folder(output_folder: &Path) -> std::io::Result<()> {
1817
}
1918
fs::create_dir_all(output_folder)?;
2019

21-
// Create a .gitignore file that ignores everything except itself
22-
let gitignore_path = output_folder.join(".gitignore");
23-
let mut file = fs::File::create(gitignore_path)?;
24-
writeln!(
25-
file,
26-
"*\n!.gitignore"
27-
)?;
28-
2920
Ok(())
3021
}
3122

@@ -130,6 +121,10 @@ fn copy_html_and_assets(src: &Path, dst: &Path, temp_root: &Path) -> Result<(),
130121
let dst_path = dst.join(entry.file_name());
131122

132123
if src_path.is_dir() {
124+
// Skip .git directory
125+
if entry.file_name() == ".git" {
126+
continue;
127+
}
133128
// Recursively copy directories
134129
copy_html_and_assets(&src_path, &dst_path, temp_root)?;
135130
} else if src_path.is_file() {
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Generate Diagrams and Traces SVG on PR Merge
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- main
8+
9+
jobs:
10+
generate-diagrams:
11+
if: github.event.pull_request.merged == true && !startsWith(github.event.pull_request.head.ref, 'release/')
12+
name: Generate and Commit Diagrams
13+
runs-on: ubuntu-latest
14+
15+
permissions:
16+
contents: write # Required to commit to the repository
17+
18+
steps:
19+
- name: Checkout Repository
20+
uses: actions/checkout@v4
21+
with:
22+
ref: main # Checkout the main branch
23+
fetch-depth: 0 # Get full history for proper Git operations
24+
25+
- name: Set up Rust
26+
uses: dtolnay/rust-toolchain@stable
27+
28+
- name: Cache Cargo dependencies
29+
uses: Swatinem/rust-cache@v2
30+
31+
- name: Build Reqvire
32+
run: |
33+
cargo build --release
34+
cp target/release/reqvire ./reqvire
35+
36+
- name: Configure Git
37+
run: |
38+
git config --global user.name "GitHub Action"
39+
git config --global user.email "actions@github.com"
40+
41+
- name: Generate Diagrams
42+
run: |
43+
./reqvire generate-diagrams
44+
45+
- name: Check for Changes
46+
id: check_changes
47+
run: |
48+
if [[ -n "$(git status --porcelain)" ]]; then
49+
echo "HAS_CHANGES=true" >> $GITHUB_ENV
50+
else
51+
echo "HAS_CHANGES=false" >> $GITHUB_ENV
52+
fi
53+
54+
- name: Commit and Push Changes
55+
if: env.HAS_CHANGES == 'true'
56+
run: |
57+
git add -A
58+
git commit -m "Auto-generate diagrams after PR merge to main"
59+
git push origin main

html/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)