Developer's Notes
+DNote's Own Notes
CREDIT
+TEST
+-
+
lib/dnote.rb
-
+
- + This is a test of an arbitrary label. 4 + +
+
CREDIT
-
-
lib/dnote/string.rb
-
-
- Trans 19 -
- Gavin Sinclair 37 -
- Gavin Sinclair 50 -
- Trans 51 +
lib/dnote/core_ext.rb
TODO
+TODO
-
-
test/cases/notes_case.rb
-
-
- Do something or another!", 1, "foo.rb" 27 -
- Do something or another!", 1, "foo.rb" 34 -
- lib/dnote/notes.rb
-
-
- Add ability to read header notes. They often -have a outline format, rather then the single line. 16 -
- Play gold with Notes#parse. 73 -
- should this be done? 79 -
- ruby-1.9.1-p378 reports: `match': invalid byte sequence in UTF-8 134 -
- Would to_xoxo be better organized by label and or file? 254 -
- lib/plugins/syckle/dnote.rb
-
-
- Should this service be part of the +site+ cycle? 18 -
- Is #trial? correct? 79 -
- work/site.rb
-
-
- Don't use chdir. 102 -
lib/dnote/format.rb
-
TEST
--
-
lib/dnote.rb
-
-
- This is a test of arbitraty labels. 31 -
-
NOTE
--
-
lib/dnote.rb
-
-
- Toying with the idea of making DNote a class. 6 +
lib/dnote/note.rb
- lib/dnote/string.rb
-
-
- This may still need a bit of tweaking. 17 -
- work/command.rb
-
-
- If DNote were a class. 139 +
lib/dnote/notes.rb

-
D'Note
-Developer's take note! All those TODO's and FIXME's floating around - your source code are rotting away. They are trapped, and in desperate need of your attention.
+ code, pre, kbd { + font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; + font-size: 0.86em; + } -But not to fret! D'Note will help you liberate them. D'Note will scan your - source code for labeled comments; collect, collate and sort them; and then return them to you in a - format of your choosing. Wunderbar!
+ /* The desk: navigation along the top. */ + .desk { + display: flex; + flex-wrap: wrap; + gap: 0.25rem 1.5rem; + justify-content: center; + padding: 0.9rem 1rem; + font-family: system-ui, sans-serif; + font-size: 0.85rem; + letter-spacing: 0.03em; + } + .desk a { color: var(--desk-text); text-decoration: none; } + .desk a:hover { color: #fff; text-decoration: underline; } + + /* The pad. */ + .pad { + position: relative; + max-width: 52rem; + margin: 0 auto 3rem; + background: + linear-gradient(to right, transparent 3.4rem, var(--margin) 3.4rem, var(--margin) calc(3.4rem + 2px), transparent calc(3.4rem + 2px)), + repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--line) - 1px), var(--rule) calc(var(--line) - 1px), var(--rule) var(--line)), + var(--paper); + background-position: 0 0, 0 0.45rem, 0 0; + border-radius: 4px; + box-shadow: 0 1px 0 var(--paper-edge), 0 4px 0 -1px var(--paper), 0 5px 0 -1px var(--paper-edge), 0 18px 40px rgba(0, 0, 0, 0.45); + } -Note Structure
+ /* The binding along the top of the pad. */ + .binding { + height: 3.5rem; + border-radius: 4px 4px 0 0; + background: linear-gradient(#8a2a24, #6d201b); + border-bottom: 3px solid #4d1612; + } -D'Note scans for the common "LABEL:" pattern (all-caps label followed by a colon) used by many - developers of many languages. To be more specific, for D'Note to recognize a note, it needs to - conform to the following simple set of rules:
+ .sheet { padding: 1.75rem 2rem 3.5rem 4.6rem; } -1) Notes start with an all-caps label punctuated with a colon, followed by the note's text.
+ header h1 { + margin: 0; + font-size: clamp(3.2rem, 11vw, 6rem); + line-height: 1.05; + letter-spacing: -0.02em; + font-weight: 700; + } + header h1 span { color: var(--accent); } -- # LABEL: description ... -+ .tagline { + margin: 0.4rem 0 0; + font-family: system-ui, sans-serif; + font-size: 0.95rem; + color: var(--ink-soft); + } - + h2 { + margin: 3.5rem 0 0.75rem; + font-size: 1.6rem; + line-height: 1.2; + } + h2::before { + content: "ยง"; + position: absolute; + left: 1.15rem; + color: var(--margin); + font-weight: 400; + } -
2) Any note that requires more than one line must remain flush to the left - margin (the margin is set by the first line). This is done because RDoc will mistake - the second line for a <pre> block if it is indented.
+ h3 { margin: 2rem 0 0.25rem; font-size: 1.1rem; } -- # LABEL: description ... - # continue ... -+ p { margin: 0 0 var(--line); } + ul, ol { margin: 0 0 var(--line); padding-left: 1.3rem; } + li { margin: 0; } -
3) An alternative to the limitation of the last rule is to indent the whole note (making - the whole note a <pre> block with regards to RDoc). Then the text layout is - free-form.
+ p code, li code { + background: rgba(35, 38, 45, 0.08); + padding: 0.1em 0.35em; + border-radius: 3px; + white-space: nowrap; + } -- # This is a description of something... - # - # LABEL: description ... - # continue ... -+ pre { + margin: 0 0 var(--line); + padding: 1rem 1.2rem; + background: var(--code-bg); + color: var(--code-text); + border-radius: 6px; + line-height: 1.5; + overflow-x: auto; + box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2); + } + pre .c { color: #9aa3b5; } + pre .l { color: #f2b56b; font-weight: 700; } + pre .p { color: #7f8798; user-select: none; } + + .install { + display: inline-block; + margin: 1.75rem 0 0; + padding: 0.7rem 1.2rem; + font-size: 1rem; + } -
That's all there is to it. If I can convince the developers of RDoc to add recognition of - labels, we may eventually be able to relax the flush rule too, which would be very nice.
- -There is also a command-line option, --no-colon, which deactives the need for
- a colon after the note label. However this often produces false positives, so it's use is
- discouraged.
Generating Notes
+ table { + width: 100%; + border-collapse: collapse; + margin: 0 0 var(--line); + background: rgba(255, 255, 255, 0.45); + font-size: 0.95rem; + } + th, td { padding: 0.35rem 0.6rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); } + th { font-family: system-ui, sans-serif; font-size: 0.8rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-soft); } + .scroll { overflow-x: auto; } + + footer { + max-width: 52rem; + margin: 0 auto; + padding: 0 1rem 3rem; + color: var(--desk-text); + font-family: system-ui, sans-serif; + font-size: 0.85rem; + text-align: center; + } + footer a { color: #fff; } + + @media (max-width: 40rem) { + html { font-size: 16px; } + .pad { margin: 0 0.5rem 2rem; background-position: -1.6rem 0, 0 0.45rem, 0 0; } + .sheet { padding: 1.25rem 1rem 2.5rem 2.6rem; } + h2::before { left: 0.35rem; } + .rules > li::before { left: -2.4rem; } + } -As you can see the commandline interface is quite straight-forward.
+ @media print { + body { background: #fff; } + .desk { display: none; } + .pad { box-shadow: none; } + } + + + + + + +D'Note
+Developer's notes, extracted from source code. For Ruby, and most other languages.
+Developers, take note! All those TODOs and FIXMEs floating around + your source code are rotting away. They are trapped, and in desperate need of your attention.
-- USAGE: ++But not to fret! D'Note will help you liberate them. D'Note will scan your + source code for labeled comments; collect, collate and sort them; and then return them to you in a + format of your choosing. Wunderbar!
- dnote [OPTIONS] path1 [path2 ...] - - OUTPUT FORMAT: (choose one) - -f, --format NAME select a format [text] - -C, --custom FILE use a custom ERB template - --file shortcut for text/file format - --list shortcut for text/list format +$ gem install dnote+ +Note Structure
+ +D'Note scans for the common
+ +LABEL:pattern, an all-caps label followed by a colon, + used by many developers of many languages. To be more specific, for D'Note to recognize a note + it needs to conform to this simple set of rules:+
+ +- +
+Notes start with an all-caps label punctuated with a colon, followed by the note's text.
+# LABEL: description ...+- +
+Any note that requires more than one line must remain flush to the left + margin (the margin is set by the first line). This is done because RDoc will mistake + the second line for a
+<pre>block if it is indented.# LABEL: description ... +# continue ...+- +
+An alternative to the limitation of the last rule is to indent the whole note (making + the whole note a
+<pre>block with regards to RDoc). Then the text layout is + free-form.# This is a description of something... +# +# LABEL: description ... +# continue ...+That's all there is to it. A note ends at a blank comment line or at a line of code. + In the future the parsing may improve to allow page-top outlined notes as well.
+ +There is also a command-line option,
- OTHER OPTIONS: - -l, --label LABEL labels to collect - --[no-]colon match labels with/without colon suffix - -m, --marker MARK alternative remark marker - -u, --url TEMPLATE url template for line entries (for HTML) - -c, --context INTEGER number of lines of context to display - -x, --exclude PATH exclude file or directory - -i, --ignore NAME ignore file based on any part of pathname - -t, --title TITLE title to use in header - -o, --output PATH save to file or directory - -n, --dryrun do not actually write to disk - --debug debug mode - - COMMAND OPTIONS: - -T, --templates list available format templates - -h, --help show this help information ---no-colon, which deactivates the need for + a colon after the note label. However this often produces false positives, so its use is + discouraged.
Tags
+ +A note can also be written as a tag, in the manner of + YARD. A tag needs no colon.
+ +# @TODO description ...
+# continue ...
+# @return [String] not part of the note
+
+ | Written as | Collected? |
|---|---|
@TODO, @WHATEVER | Always. A tag in capitals is a note. |
@todo, @fixme, @optimize, @think, @deprecate | Yes. The usual labels count in lower case too, so YARD's own @todo is picked up. |
@param, @return, @note | No. These are documentation. Ask by name to collect one: --label NOTE. |
There are a variety of formats are available, here are examples of some of the
- XML, HTML and YAML
- formats. You can get a list of all available format templates using the -T option.
A tag note ends at the next tag, as well as at a blank comment line or a line of code.
+ To turn tags off, use --no-tags.
YARD itself warns of a tag it doesn't know, such as @FIXME. To have YARD
+ accept one, name it in .yardopts:
--tag FIXME:"Fix Me" +--hide-tag FIXME+ +
Generating Notes
+ +As you can see the command-line interface is quite straightforward.
+ +USAGE: + dnote [OPTIONS] path1 [path2 ...] + +OUTPUT FORMAT: (choose one) + -f, --format NAME select a format [text] + -C, --custom FILE use a custom ERB template + --file shortcut for text/file format + --list shortcut for text/list format + +OTHER OPTIONS: + -l, --label LABEL labels to collect + --[no-]colon match labels with/without colon suffix + --[no-]tags match labels written as tags, e.g. @TODO [yes] + -m, --marker MARK alternative remark marker + -u, --url TEMPLATE url template for line entries (for HTML) + -c, --context INTEGER number of lines of context to display + -x, --exclude PATH exclude file or directory + -i, --ignore NAME ignore file based on any part of pathname + -t, --title TITLE title to use in header + -o, --output PATH save to file or directory + -n, --dryrun do not actually write to disk + --debug debug mode + +COMMAND OPTIONS: + -T, --templates list available format templates + -h, --help show this help information+ +
The default path is **/*.rb and the default format is -f text.
+ A path that is a directory takes in everything below it. The comment marker is chosen by
+ a file's extension; use --marker for any other.
Here are some of D'Note's own notes:
+ +$ dnote -l TODO lib/dnote/format.rb lib/dnote/note.rb
+Developer's Notes
+
+TODO
+
+ 1. Need good CSS file. (lib/dnote/format.rb:12)
+ 2. Need XSL? (lib/dnote/format.rb:14)
+ 3. Add +url+? (lib/dnote/note.rb:70)
+ 4. Add +code+? Problem is that xml needs code in CDATA. (lib/dnote/note.rb:71)
+
+(4 TODOs)
+
+ Formats
+ +A variety of formats are available. Here is D'Note's own source in a few of them: + HTML, Markdown, + XML, YAML and + JSON.
+ +| Format | What you get |
|---|---|
text | Plain text, the default. |
md, rdoc | Markdown or RDoc, ready to add to your documentation. |
html | A page of its own. Give --url to link each note to its line. |
xml, json, yaml | Data, for other tools. |
soap, xoxo | Need the soap4r-ng and xoxo gems, which aren't installed with D'Note. |
The default path is **/*.rb and the default format -f text.
- Here is an example of DNote's own notes in -f rdoc format:
Each arranges the notes by label and then by file. Add /file,
+ /label or /list for another arrangement, as in
+ -f md/list. The -T option lists them all.
- = Development Notes ++For anything else, write an ERB template and pass it with
- == TODO +--custom. + It hasnotesandtitleto work with.Rake Task
- === file://lib/dnote/notes.rb +require 'dnote/rake/dnotetask' - * TODO: Add ability to read header notes. They often - have a outline format, rather then the single line. (19) - * TODO: Need CSS? (22) - * TODO: Need XSL? (24) +DNote::RakeTask.new do |t| + t.files = 'lib/**/*.rb' + t.formats = ['html', 'md'] + t.output = 'doc/notes' +end- === file://plug/syckle/services/dnote.rb +This defines a
- * TODO: Should this service be part of the +site+ cycle? (18) +dnotetask, which writesdoc/notes/notes.html+ anddoc/notes/notes.md, and adnote:clobbertask that removes them.With YARD
- (4 TODOs) -
To add the notes to YARD documentation, write them to a file and list it in
+ .yardopts with the other extra files.
In the future the parsing may imnprove to allow page-top outlined notes as well.
+$ dnote -f md -o NOTES.md
-
-