[pbs-devel] [PATCH proxmox-backup v4 6/6] docs/api-viewer: improve rendering of array format
Dominik Csapak
d.csapak at proxmox.com
Mon May 10 11:28:00 CEST 2021
by showing
'[format, ...]'
where 'format' is the simple format from the type of the items
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
docs/api-viewer/PBSAPI.js | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/docs/api-viewer/PBSAPI.js b/docs/api-viewer/PBSAPI.js
index 2417b4de..3f08418e 100644
--- a/docs/api-viewer/PBSAPI.js
+++ b/docs/api-viewer/PBSAPI.js
@@ -86,13 +86,9 @@ Ext.onReady(function() {
return pdef['enum'] ? 'enum' : (pdef.type || 'string');
};
- var render_format = function(value, metaData, record) {
- var pdef = record.data;
-
- metaData.style = 'white-space:normal;'
-
+ let render_simple_format = function(pdef, type_fallback) {
if (pdef.typetext)
- return Ext.htmlEncode(pdef.typetext);
+ return pdef.typetext;
if (pdef['enum'])
return pdef['enum'].join(' | ');
@@ -101,9 +97,28 @@ Ext.onReady(function() {
return pdef.format;
if (pdef.pattern)
- return Ext.htmlEncode(pdef.pattern);
+ return pdef.pattern;
+
+ if (pdef.type === 'boolean')
+ return `<true|false>`;
+
+ if (type_fallback && pdef.type)
+ return `<${pdef.type}>`;
+
+ return;
+ };
+
+ let render_format = function(value, metaData, record) {
+ let pdef = record.data;
+
+ metaData.style = 'white-space:normal;'
+
+ if (pdef.type === 'array' && pdef.items) {
+ let format = render_simple_format(pdef.items, true);
+ return `[${Ext.htmlEncode(format)}, ...]`;
+ }
- return '';
+ return Ext.htmlEncode(render_simple_format(pdef) || '');
};
var real_path = function(path) {
--
2.20.1
More information about the pbs-devel
mailing list