Skip to content

Commit

Permalink
docs: update cvars list
Browse files Browse the repository at this point in the history
also add pipe escape, path fallback, cvar filter, and EOF LF to cvars.js
also add contribution tutorial for generator
TODO: should cvars.js be in docs? to make it more obvious what it's for
  • Loading branch information
ThisAMJ authored and NeKzor committed Oct 25, 2023
1 parent cbdc056 commit 8abef6c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 33 deletions.
12 changes: 9 additions & 3 deletions cvars.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class Cvar {
}
};

fs.readFile(process.argv[2] + '/sar.cvars', 'utf-8', (err, data) => {
let path = process.argv[2] || process.cwd();

fs.readFile(path + '/sar.cvars', 'utf-8', (err, data) => {
if (err) {
return console.error(err);
}
Expand All @@ -25,6 +27,9 @@ fs.readFile(process.argv[2] + '/sar.cvars', 'utf-8', (err, data) => {
}
}

// Hide internal and user-defined config+ cvars
cvars = cvars.filter(e => !(e.name.startsWith('_') || e.description == "SAR function command.\n" || e.description == "SAR alias command.\n"));

const compareCvar = (a, b) => {
if (a.startsWith('-') || a.startsWith('+')) {
a = a.substring(1);
Expand All @@ -39,12 +44,13 @@ fs.readFile(process.argv[2] + '/sar.cvars', 'utf-8', (err, data) => {
for (let cvar of cvars.sort((a, b) => compareCvar(a.name, b.name))) {
body += '\n|';
body += (cvar.games.length > 0) ? `<i title="${cvar.games.join('&#10;')}">${cvar.name}</i>` : cvar.name;
body += `|${cvar.value}|${cvar.description.replace(/</g, '\\<').replace(/\n/g, '<br>')}|`;
body += `|${cvar.value}|${cvar.description.replace(/([<\|])/g, '\\$1').replace(/\n/g, '<br>')}|`;
}

fs.writeFileSync('docs/cvars.md',
`# SAR: Cvars
|Name|Default|Description|
|---|---|---|${body}`);
|---|---|---|${body}
`);
});
5 changes: 5 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ auto funcAddress = Memory::Absolute(MODULE("engine"), 0xdeadbeef);

### Console Commands

Periodically, the `docs/cvars.md` file should be updated to match the list of
cvars. This can be done by doing the `sar_cvars_dump_doc` command ingame,
then doing `node "<path to SAR>/cvars.js" "<path to Portal 2>"` (assuming you
have NodeJS).

#### Variables

```cpp
Expand Down
Loading

0 comments on commit 8abef6c

Please sign in to comment.