-
Notifications
You must be signed in to change notification settings - Fork 27
Refactor with architecture and developer documentation #865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
macumber
wants to merge
27
commits into
develop
Choose a base branch
from
add_documentation
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
e118470
First draft
macumber e1f02cc
Merge remote-tracking branch 'origin/develop' into add_documentation
macumber 8580809
refactor: extract openstudio_qt_utils; reorganize shared_gui_components
macumber 818371d
Missed a few updates
macumber f6edaa9
Update docs
macumber 0c30778
Merge remote-tracking branch 'remotes/origin/cleanup_dependencies' in…
macumber cd14117
Update llms.txt
macumber 8a1cf18
Fix copilot review comments
macumber f94ed1c
Remove all SWIG files
macumber b081f8e
Address link errors on Ubuntu
macumber 94fe5c3
Remove unused class
macumber 3b2d037
fix(linux): fix linker errors caused by shared_gui_components referen…
macumber 4048582
Remove references to Jenkins file and update docs
macumber 969392a
Remove InspectorDialog top level widget
macumber bd12f80
Fix include guard
macumber 3983c6b
Apply review comments
macumber 5113df6
Remove dead code and fix CI issues for Ubuntu
macumber 9792342
Fix tech debt issues identified
macumber 6b62156
Introduce BaseDocument abstract interface in shared_gui_components an…
macumber 989a668
Clang format
macumber fd9565c
Fix review issues
macumber 0fa88b1
Normalize includes and fix Mac warning treated as error
macumber 7868a04
Fix issues found on manual review
macumber 5707722
Add script to sort includes, will run this on a separate pr
macumber fe41f15
Revert changes to this file
macumber 66b7087
Add removed doc strings and improve TODO comment
macumber 4cf35d9
Clang format
macumber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| --- | ||
| description: "Use when moving, renaming, or refactoring C++ classes in src/. Covers include order, git mv, shared_ptr vs raw pointer, and C++ covariance rules." | ||
| applyTo: "src/**/*.cpp,src/**/*.hpp,src/**/CMakeLists.txt" | ||
| --- | ||
|
|
||
| # C++ Refactoring Guidelines | ||
|
|
||
| ## Include Order | ||
|
|
||
| Within every `.cpp` and `.hpp`, includes must appear in this order, with a blank line between each group: | ||
|
|
||
| ```cpp | ||
| // 1. Own header (in .cpp only — the header this .cpp implements) | ||
| #include "ThisClass.hpp" | ||
|
|
||
| // 2. Same-directory relative includes | ||
| #include "Sibling.hpp" | ||
|
|
||
| // 3. Cross-directory repo includes | ||
| #include "../other_module/Foo.hpp" | ||
|
|
||
| // 4. OpenStudio SDK includes | ||
| #include <openstudio/model/Model.hpp> | ||
|
|
||
| // 5. Qt, Boost, and system includes | ||
| #include <QWidget> | ||
| #include <boost/optional.hpp> | ||
| #include <memory> | ||
| ``` | ||
|
|
||
| Do not mix groups. When adding a new include, place it in the correct group in the same edit — not as a deferred cleanup. Within each group, sort includes alphabetically by filename. | ||
|
|
||
| --- | ||
|
|
||
| ## Naming | ||
|
|
||
| When introducing an interface method, choose its name before writing any code: | ||
|
|
||
| - Prefer names that describe the *concept*, not the return type (`currentDocument`, not `currentBaseDocument`). | ||
| - Check for name collisions with existing virtuals in the inheritance chain before committing. | ||
| - A rename that touches 100+ files is expensive; settle the name at design time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --- | ||
| description: "Use when reviewing pull requests, conducting code review, or checking a diff for correctness. Covers documentation accuracy checks for developer/doc/." | ||
| --- | ||
|
|
||
| # Pull Request Review Guidelines | ||
|
|
||
| On every PR review, verify documentation and comments are consistent with the code changes: | ||
|
|
||
| **`developer/doc/` docs** | ||
| - `CMakeLists.txt` changed → check the corresponding `libraries/*.md` for stale dependency tables or target names; check `architecture.md` dependency graph. | ||
| - Class added/moved/deleted → check library doc's Key Classes section is accurate and the header has a `/** */` doc comment. | ||
|
|
||
| **Inline comments** | ||
| - Significant class added or refactored (`src/**/*.hpp`) → `/** */` comment above the class must exist, describe current responsibility, and contain no stale references. | ||
| - Workflow added or modified (`.github/workflows/*.yml`) → `#` comment block at top must accurately reflect purpose, triggers, and required secrets. | ||
| - CI script added or modified (`ci/*.sh`, `ci/*.py`, `ci/*.qs`) → header comment must accurately describe usage, arguments, and exit codes. | ||
|
|
||
| > Full standards: [`.github/prompts/update-docs.prompt.md`](../prompts/update-docs.prompt.md) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,251 @@ | ||
| --- | ||
| mode: agent | ||
| description: Update and maintain the OpenStudio Application developer documentation in developer/doc/ | ||
| tools: | ||
| - read_file | ||
| - grep_search | ||
| - file_search | ||
| - semantic_search | ||
| - replace_string_in_file | ||
| - create_file | ||
| - multi_replace_string_in_file | ||
| applyTo: | | ||
| developer/doc/**/*.md | ||
| src/**/*.hpp | ||
| src/**/*.cpp | ||
| .github/workflows/**/*.yml | ||
| ci/** | ||
| CMakeLists.txt | ||
| src/**/CMakeLists.txt | ||
| --- | ||
|
|
||
| # Documentation Maintenance Agent | ||
|
|
||
| You are a senior developer on the OpenStudio Application project. Your task is to keep the documentation in `developer/doc/` accurate and complete. All documentation is written in Markdown with embedded Mermaid diagrams. The audience is the internal development team (C++/Qt background assumed). | ||
|
|
||
| --- | ||
|
|
||
| ## 1. Documentation Structure Map | ||
|
|
||
| Every source file has a corresponding documentation home. Consult this map before editing any doc: | ||
|
|
||
| ``` | ||
| developer/doc/ | ||
| ├── architecture.md ← CMakeLists.txt, README.md, all module CMakeLists.txt | ||
| ├── libraries/ | ||
| │ ├── openstudio_app.md ← src/openstudio_app/CMakeLists.txt + headers | ||
| │ ├── openstudio_lib.md ← src/openstudio_lib/CMakeLists.txt + headers | ||
| │ ├── shared_gui_components.md ← src/shared_gui_components/CMakeLists.txt + headers | ||
| │ ├── openstudio_qt_utils.md ← src/openstudio_qt_utils/CMakeLists.txt + headers | ||
| │ ├── model_editor.md ← src/model_editor/CMakeLists.txt + headers | ||
| │ ├── bimserver.md ← src/bimserver/CMakeLists.txt + headers | ||
| │ └── utilities.md ← src/utilities/CMakeLists.txt | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 2. Trigger Conditions | ||
|
|
||
| Update documentation when ANY of the following changes occur: | ||
|
|
||
| | Change | Docs to update | | ||
| |---|---| | ||
| | `CMakeLists.txt` in a module changes (new deps, new targets) | Corresponding library `.md` + `architecture.md` dependency graph | | ||
| | `src/openstudio_qt_utils/` file modified | `libraries/openstudio_qt_utils.md` | | ||
| | Top-level `CMakeLists.txt` changes (version, new sub-project) | `architecture.md` | | ||
| | `conanfile.py` dependency version changes | `architecture.md` tech stack section | | ||
|
|
||
| --- | ||
|
|
||
| ## 3. Document Templates | ||
|
|
||
| ### 3a. Architecture Document (`architecture.md`) | ||
|
|
||
| ```markdown | ||
| # OpenStudio Application — Architecture | ||
|
|
||
| > Version: {version} | Tech stack: C++20, Qt {qt_version}, CMake+Conan 2 | ||
|
|
||
| ## 1. System Context | ||
|
|
||
| \`\`\`mermaid | ||
| C4Context | ||
| title System Context — OpenStudio Application | ||
| Person(user, "Energy Modeler", "...") | ||
| System(app, "OpenStudio Application", "...") | ||
| ... | ||
| \`\`\` | ||
|
|
||
| ## 2. Container View | ||
|
|
||
| \`\`\`mermaid | ||
| C4Container | ||
| ... | ||
| \`\`\` | ||
|
|
||
| ## 3. Module Dependency Graph | ||
|
|
||
| \`\`\`mermaid | ||
| flowchart LR | ||
| ... | ||
| \`\`\` | ||
|
|
||
| ## 4. Technology Stack | ||
|
|
||
| | Category | Technology | Version | | ||
| |---|---|---| | ||
| | ... | ||
|
|
||
| ## 5. Key Design Patterns | ||
|
|
||
| ... | ||
|
|
||
| ## 6. CI/CD Integration | ||
|
|
||
| ... | ||
|
|
||
| ## 7. Module Index | ||
|
|
||
| | Module | Library | Doc | | ||
| |---|---|---| | ||
| | ... | ||
| ``` | ||
|
|
||
| ### 3b. Library Document (`libraries/{name}.md`) | ||
|
|
||
| ```markdown | ||
| # Library: `{name}` | ||
|
|
||
| > CMake target: `openstudio_{name}` | Location: `src/{name}/` | ||
|
|
||
| ## Purpose | ||
| One-paragraph description of responsibility. | ||
|
|
||
| ## Mermaid Context | ||
| \`\`\`mermaid | ||
| flowchart LR | ||
| {name}["**{name}**\n..."] --> dep1["dependency"] | ||
| \`\`\` | ||
|
|
||
| ## Key Classes | ||
| | Class | Role | | ||
| |---|---| | ||
|
|
||
| ## Dependencies | ||
| | Dependency | Usage | | ||
| |---|---| | ||
|
|
||
| ## Design Notes | ||
| ... | ||
|
|
||
| ## Key Classes | ||
|
|
||
| Class-level documentation is in the corresponding header files under [`src/{name}/`](../../../src/{name}/). | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 4. Mermaid Conventions | ||
|
|
||
| | Diagram type | When to use | Size limit | | ||
| |---|---|---| | ||
| | `flowchart TD/LR` | System-level context and container views (architecture.md) | — | | ||
| | `flowchart TD` / `LR` | Job step sequences (CI docs), initialization flows | — | | ||
| | `classDiagram` | Class inheritance and key methods | ≤12 nodes | | ||
| | `sequenceDiagram` | Inter-object messaging (class docs) | ≤8 participants | | ||
|
|
||
| **Rules:** | ||
| - Never use actor/entity names that contain special characters without quoting them. | ||
| - Avoid placing raw C++ template syntax inside diagram nodes; use simplified names. | ||
| - Always give diagrams a `title` line when C4 context/container type is used. | ||
| - Prefer short, readable labels. Put full detail in prose below the diagram. | ||
|
|
||
| --- | ||
|
|
||
| ## 5. Cross-Linking Rules | ||
|
|
||
| - `architecture.md` module index must link to every library doc. | ||
| - Use **relative Markdown links** only (e.g., `../libraries/openstudio_lib.md`, not absolute paths). | ||
|
|
||
| --- | ||
|
|
||
| ## 6. Step-by-Step Maintenance Procedure | ||
|
|
||
| Follow these steps whenever source code or CI configuration changes: | ||
|
|
||
| 1. **Identify changed files.** Read the diff or PR description to find which `.hpp`, `.cpp`, `.yml`, `CMakeLists.txt`, or `ci/` files were modified. | ||
|
|
||
| 2. **Map to documentation.** Use the Structure Map (§1) and Trigger Conditions (§2) to determine which `.md` files need updating. | ||
|
|
||
| 3. **Read the changed source.** Use `read_file` to read the relevant headers and CMake files. | ||
|
|
||
| 4. **Read the existing doc.** Use `read_file` on the current `.md` to understand what is already correct and what has drifted. | ||
|
|
||
| 5. **Update the doc.** Use `replace_string_in_file` for targeted edits (prefer this over full rewrites). Update: | ||
| - Dependency tables and module graphs if CMake targets changed | ||
| - Tech stack table in `architecture.md` if versions changed | ||
|
|
||
| 6. **Check for version or dependency changes.** If `CMakeLists.txt` or `conanfile.py` changed dependency versions, update the tech stack table in `architecture.md`. | ||
|
|
||
| 7. **Verify Mermaid syntax.** Ensure all diagram blocks are syntactically valid Mermaid. | ||
|
|
||
| --- | ||
|
|
||
| ## 7. Class Documentation | ||
|
|
||
| Class-level documentation lives in `/** */` doc comments in the header files (`src/**/*.hpp`), not in separate Markdown files. When adding a new significant class (base/abstract classes, major controllers, integration points, widely reused components), add a `/** ... */` doc comment block directly above the class declaration describing its purpose. | ||
|
|
||
| --- | ||
|
|
||
| ## 8. Comment Correctness and Completeness Checks | ||
|
|
||
| When source files are changed, verify that inline comments remain accurate. | ||
|
|
||
| ### C++ Header Class Comments (`src/**/*.hpp`) | ||
|
|
||
| For every significant class (base/abstract, major controller, integration point, widely reused component) that was added or modified: | ||
|
|
||
| 1. **Presence** — a `/** */` doc comment must appear directly above the class declaration (not a forward declaration). | ||
| 2. **Accuracy** — the comment must reflect the class's current responsibility. Check for: | ||
| - Purpose description that no longer matches the class's role after a refactor | ||
| - References to removed methods, renamed signals, or deleted dependencies | ||
| 3. **Completeness** — if the class is one of the following types, the comment should describe what it owns, what signals it emits, and how it fits into the broader system: | ||
| - Abstract base / interface classes | ||
| - Tab-level controllers (`*Controller` owning a `*View`) | ||
| - Classes bridging external systems (web engine, BIMserver, CLI, network) | ||
| 4. **What to skip** — do not add or require doc comments on: | ||
| - Forward declarations | ||
| - Member variables, private methods, or trivial getters/setters (unless they have non-obvious side effects) | ||
| - Private implementation detail classes nested inside a `.cpp` | ||
| - Thin wrappers or trivial value types with self-explanatory names | ||
|
|
||
| ### GitHub Actions Workflow Comments (`.github/workflows/*.yml`) | ||
|
|
||
| For every workflow file that was added or modified, verify the file-level comment block at the top: | ||
|
|
||
| 1. **Presence** — a `#`-prefixed comment block must appear before the `name:` line. | ||
| 2. **Accuracy** — check that the comment correctly describes: | ||
| - The workflow's purpose (what it builds, tests, or enforces) | ||
| - Trigger conditions (branches, tags, events, manual dispatch) | ||
| - Any required secrets (add or remove as the `secrets:` block changes) | ||
| - When to run it manually (for `workflow_dispatch` workflows) | ||
| 3. **Completeness** — the comment should be enough for a developer to understand the workflow without reading the full YAML. It does not need to enumerate every step. | ||
|
|
||
| ### CI Helper Scripts (`ci/*.sh`, `ci/*.py`, `ci/*.qs`) | ||
|
|
||
| For every script that was added or modified: | ||
|
|
||
| 1. **Presence** — a comment header describing the script's purpose must be present near the top of the file. | ||
| 2. **Accuracy** — check that usage examples, argument descriptions, and exit-code documentation still match the script's actual behaviour. | ||
|
|
||
| --- | ||
|
|
||
| ## 9. Scope Exclusions | ||
|
|
||
| Never document the following in `developer/doc/` (they are internal plumbing or generated code): | ||
|
|
||
| - Contents of `debug/` or `release/` build directories | ||
| - Files under `signatures/` | ||
| - References to BIMserver as this functionality is to be deprecated | ||
| - Generated files under `src/utilities/` (these are `configure_file` outputs) | ||
| - Contents of `ruby/` Ruby gems or vendored external libraries |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is true right now, but will likely fall out of sync. Not sure what value it really provides. You can read the workflow to understand it.
Should the workflow fail for some reason, you'll definitely need to understand it anyways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that manually maintaining this documentation would quickly become stale. However, my thought was by adding the instruction "CI script added or modified (
ci/*.sh,ci/*.py,ci/*.qs) → header comment must accurately describe usage, arguments, and exit codes." in.github\instructions\pr-review.instructions.mdthat we could rely on the co-pilot reviews to ensure it stays up to date.Part of the intent of this PR is to add documentation to guide llms in understanding the code and being able to make changes. So, my thought was we could add documentation for llms and then rely on llms to help keep it up to date. I'm open to removing it though.