Add little icons to the toc at the top to easily identify any comments mentioning TODO, BUG, WARNING, FOOTGUN, or DEPRECATED.

main
Zed A. Shaw 2 years ago
parent 372be19301
commit 2e2c7c35fb
  1. 23
      admin/pages/DocsBrowser.svelte
  2. 16
      commands/codedoc.js
  3. 6
      lib/models.js

@ -11,6 +11,14 @@
let url; let url;
export let params; export let params;
const caps_to_icon = {
"BUG": "bug",
"TODO": "clipboard-check",
"WARNING": "alert-triangle",
"FOOTGUN": "bomb",
"DEPRECATED": "axe"
}
const jump = (id) => { const jump = (id) => {
let node = document.getElementById(id); let node = document.getElementById(id);
if(node) node.scrollIntoView(); if(node) node.scrollIntoView();
@ -144,7 +152,7 @@
toc { toc {
display: grid; display: grid;
grid-template-columns: repeat(6, 1fr); grid-template-columns: repeat(5, 1fr);
} }
toc span { toc span {
@ -177,15 +185,18 @@
<toc> <toc>
{#each docs_data.exports as exp} {#each docs_data.exports as exp}
{#if exp.isa == "class"} <span on:click={ () => jump(exp.slug) }>{ exp.name }
<span on:click={ () => jump(exp.slug) }>{ exp.name }</span> {#each exp.caps as cap_word}<Icon name={ caps_to_icon[cap_word] } size="24" light={ true }/>{/each}
</span>
{#if exp.isa == "class"}
{#each exp.methods as member} {#each exp.methods as member}
<span on:click={ () => jump(member.slug) }>.{ member.name }</span> <span on:click={ () => jump(member.slug) }>.{ member.name }
{#each member.caps as cap_word}<Icon name={ caps_to_icon[cap_word] } size="24" light={ true } />{/each}
</span>
{/each} {/each}
{:else}
<span on:click={ () => jump(exp.slug) }>{ exp.name }</span>
{/if} {/if}
{/each} {/each}
</toc> </toc>
</module-header> </module-header>

@ -27,6 +27,7 @@ export const required = [
] ]
const RENDERER = create_renderer(); const RENDERER = create_renderer();
const CAPS_WORDS = ["BUG", "TODO", "WARNING", "FOOTGUN", "DEPRECATED"];
const slug = (instring) => slugify(instring, { lower: true, strict: true, trim: true}); const slug = (instring) => slugify(instring, { lower: true, strict: true, trim: true});
@ -93,6 +94,8 @@ class ParseWalker {
comment: this.find_comment(meth_node.loc.start.line), comment: this.find_comment(meth_node.loc.start.line),
} }
this.has_CAPS(new_method);
new_method.code = this.slice_code(new_method.range); new_method.code = this.slice_code(new_method.range);
new_class.methods.push(new_method); new_class.methods.push(new_method);
@ -127,11 +130,24 @@ class ParseWalker {
return result; return result;
} }
/*
Used to add information when something is mentioned in the
comment like BUG, TODO, etc.
*/
has_CAPS(exp) {
if(exp.comment) {
exp.caps = CAPS_WORDS.filter(phrase => exp.comment.includes(phrase));
} else {
exp.caps = [];
}
}
add_export(id, exp) { add_export(id, exp) {
exp.name = id.name; exp.name = id.name;
exp.slug = exp.slug ? exp.slug : slug(id.name); exp.slug = exp.slug ? exp.slug : slug(id.name);
exp.line_start = id.loc.start.line; exp.line_start = id.loc.start.line;
exp.comment = this.find_comment(exp.line_start); exp.comment = this.find_comment(exp.line_start);
this.has_CAPS(exp);
exp.code = this.slice_code(exp.range); exp.code = this.slice_code(exp.range);
this.exported.push(exp); this.exported.push(exp);
} }

@ -100,7 +100,10 @@ export class User extends Model.from_table('user') {
/* /*
Performs all the cleanup and checks needed for a registration. It will Performs all the cleanup and checks needed for a registration. It will
ensure that the password and password_repeat are the same, lowercase the email, ensure that the password and password_repeat are the same, lowercase the email,
clean out unwanted attrbiutes with User.clean, generate required keys, etc. clean out unwanted attributes with `User.clean`, generate required keys, etc.
- BUG: Test out bugs feature.
- TODO: Test out todo feature.
+ `attr Object` - attributes usually from a web form + `attr Object` - attributes usually from a web form
+ ___return___ `Object`, `undefined` or the new user on success + ___return___ `Object`, `undefined` or the new user on success
@ -124,7 +127,6 @@ export class User extends Model.from_table('user') {
log.error("User exists", user.email); log.error("User exists", user.email);
return undefined; return undefined;
} else { } else {
// BUG: accepting unfiltered user input
user.password = User.encrypt_password(user.password); user.password = User.encrypt_password(user.password);
user.unsubkey = User.random_hex(UNSUB_CODE_SIZE); user.unsubkey = User.random_hex(UNSUB_CODE_SIZE);

Loading…
Cancel
Save