jasraj / q-doc Goto Github PK
View Code? Open in Web Editor NEWJavadoc inspired documentation generator for kdb+
License: BSD 3-Clause "New" or "Revised" License
Javadoc inspired documentation generator for kdb+
License: BSD 3-Clause "New" or "Revised" License
I find that parsing fails entirely when the system "l" command is present, i.e. the first one fails whereas the second one works
$ cat test.q
system "d";
/ print hello world
.test.f:{show "hello world";};
$ cat test.q
/system "d";
/ print hello world
.test.f:{show "hello world";};
This is an issue since a) not using system "d" to go into a context means you have to qualify every function name (which I don't actually mind so much, it's a bit tedious but it's more explicit so has its own advantages) but b) you may not always have control over loaded libraries.
In my case I am loading a q script which is external to me which makes use of the system "l" command. That fails my parser entirely.
How keen are you to add more comment tag support, including some of the useful in-line tags?
I've completed the following addition in my own fork:
@see
external link support: / @see <a href="....">...</a>
{@code ...}
(including the <code>...</code>
alias){@literal ...}
(including the <tt>...</tt>
alias)/ q) ....
or / k)....
Please kindly let me know if you are interested these features as additional a pull request.
Hi Jas
We're having a look at this, looks good and a fit for what we need. I tried to do a PR for a small change to support macs, but was denied access. This is the change:
diff --git a/q-doc.q b/q-doc.q
index 884398d..f5306cb 100644
--- a/q-doc.q
+++ b/q-doc.q
@@ -50,7 +50,7 @@
:hsym first `$trim system "echo %cd%";
];
if["l"~first string .z.o;
if[(first string .z.o) in "lm";
:hsym first `$trim system "pwd";
];
Would you be able to add that?
Thanks
Jonny
Thanks for the code, I find it very useful. I added an @example tag that parses an example function call.
I did realize however that the parser can have troubles with certain functions. One such case is backlashes in one line function bodies.
Example:
/ backslash in function falls over
/ @param input (String) list of strings
/ @returns (List) of strings, comma appended
f:{[input] : input ,:","};
/ same function, multiline, with backslash in between
/ @param input (String) list of strings
/ @returns (List) of strings, comma appended
h:{
[input] : input ,:","
};
h gets parsed correctly, f does not
Use https://github.com/BuaBook/kdb-common as the core of the application.
Hi Jasraj,
I have tried your q-doc on my Q codebase. It works great. But, my concern is that I want to save the documentation on disk and want to see the documentation on demand offline i.e. I don't want it to be running as a service. Is there a workaround to do it?
I am not very proficient in Javascript or JSON.
Thanks,
Shatrughan.
If there is no function description all other supported q-doc syntax gets ignored. Add support to allow documentation where there is no function description.
Hi Jas
Ok so I'm not really asking you to do this - more asking advice if you think there would be any issues doing them, or if there is currently a way. If we do them we would hope to submit the changes back to the repo as PRs.
Thanks
Jonny
Possibly a rather obscure edge case. The last function causes the parsing of the entire file to fail
/ return true if true is true, no params
/ works
g:{ if[1b=1b;:1b };
/ show true if true is true, no params
/ works
k:{if[1b=1b; show "true"]};
/ return true if true is true, params
/ works
l:{[]if[1b=1b;:1b]};
/ show true if true is true - this one fails the whole file
/ fails
/j:{[] if[1b=1b; show "true"]};
A possible bugfix:
------------------------------- q-doc-parser.q --------------------------------
index 448f4c1..e4761d7 100644
@@ -132,8 +132,8 @@
namespaces:fills?[namespaceSwitches;`$2_/:funcSignatures;`];
/ Recover namespace for each function
- funcAndArgs:(!). flip(({$[(~).(first;last)@\:y;`;$[(null x)or(y[0]like ".*");::;` sv x,]`$y 0]}@/:namespaces),\:last)@\:'":"vs/:funcSignatures;
- funcAndArgs:{ $[not "{["~2#x; :enlist`$"..."; :`$";" vs x where not any x in/:"{[]} "] } each funcAndArgs;
+ funcAndArgs:(!). flip(({$[(~).(first;last)@\:y;`;$[(null x)or(y[0]like ".*");::;` sv x,]`$y 0]}@/:namespaces),\:{":"sv 1_x})@\:'":"vs/:funcSignatures;
+ funcAndArgs:{ $[not "{["~2#x; :enlist`$"..."; :`$";" vs x where not any((count[x]^first x ss"]")#x)in/:"{[]} "] } each funcAndArgs;
commentLines:{last[y]+(last[y]_x)?z}[file]\[0;funcSignatures];
commentLines:commentLines - til each deltas commentLines;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.