markdown-docs.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * Copyright (c) 2017-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. * @author Panagiotis Tourlas <panagiot_tourlov@hotmail.com>
  6. *
  7. * Adapted from MolQL project
  8. */
  9. import { properties } from './properties';
  10. import { operators } from './operators';
  11. import { keywords } from './keywords';
  12. import { functions } from './functions';
  13. const _docs: string[] = [
  14. 'VMD',
  15. '============',
  16. '--------------------------------',
  17. ''
  18. ];
  19. _docs.push(`## Properties\n\n`);
  20. _docs.push('--------------------------------\n');
  21. for (const name in properties) {
  22. if (properties[name].isUnsupported) continue;
  23. const names = [name];
  24. if (properties[name].abbr) names.push(...properties[name].abbr!);
  25. _docs.push(`\`\`\`\n${names.join(', ')}\n\`\`\`\n`);
  26. if (properties[name]['@desc']) {
  27. _docs.push(`*${properties[name]['@desc']}*\n`);
  28. }
  29. }
  30. _docs.push(`## Operators\n\n`);
  31. _docs.push('--------------------------------\n');
  32. operators.forEach(o => {
  33. if (o.isUnsupported) return;
  34. const names = [o.name];
  35. if (o.abbr) names.push(...o.abbr!);
  36. _docs.push(`\`\`\`\n${names.join(', ')}\n\`\`\`\n`);
  37. if (o['@desc']) {
  38. _docs.push(`*${o['@desc']}*\n`);
  39. }
  40. });
  41. _docs.push(`## Keywords\n\n`);
  42. _docs.push('--------------------------------\n');
  43. for (const name in keywords) {
  44. if (!keywords[name].map) continue;
  45. const names = [name];
  46. if (keywords[name].abbr) names.push(...keywords[name].abbr!);
  47. _docs.push(`\`\`\`\n${names.join(', ')}\n\`\`\`\n`);
  48. if (keywords[name]['@desc']) {
  49. _docs.push(`*${keywords[name]['@desc']}*\n`);
  50. }
  51. }
  52. _docs.push(`## Functions\n\n`);
  53. _docs.push('--------------------------------\n');
  54. for (const name in functions) {
  55. if (!functions[name].map) continue;
  56. const names = [name];
  57. _docs.push(`\`\`\`\n${names.join(', ')}\n\`\`\`\n`);
  58. if (functions[name]['@desc']) {
  59. _docs.push(`*${functions[name]['@desc']}*\n`);
  60. }
  61. }
  62. export const docs = _docs.join('\n');