From 6a3945bbe93dfbcf2fe0fb0b4797b4e630bfe09a Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Mon, 13 Nov 2017 12:36:08 +0300 Subject: [PATCH] all content section --- Web-documentation/all_contents.html.twig | 80 +++++++++++++ Web-documentation/blocks/class-body.html.twig | 22 ++++ Web-documentation/blocks/enum-body.html.twig | 20 ++++ Web-documentation/blocks/main-menu.html.twig | 4 + .../blocks/method-body.html.twig | 96 ++++++++++++++++ .../blocks/table-of-contents-body.html.twig | 32 ++++++ Web-documentation/js/main.js | 48 +++++++- Web-documentation/methods.html.twig | 105 ++---------------- .../structure_enumeration.html.twig | 28 +---- Web-documentation/structure_objects.html.twig | 30 +---- Web-documentation/table_of_contents.html.twig | 40 +------ 11 files changed, 324 insertions(+), 181 deletions(-) create mode 100644 Web-documentation/all_contents.html.twig create mode 100644 Web-documentation/blocks/class-body.html.twig create mode 100644 Web-documentation/blocks/enum-body.html.twig create mode 100644 Web-documentation/blocks/method-body.html.twig create mode 100644 Web-documentation/blocks/table-of-contents-body.html.twig diff --git a/Web-documentation/all_contents.html.twig b/Web-documentation/all_contents.html.twig new file mode 100644 index 0000000..44d4b52 --- /dev/null +++ b/Web-documentation/all_contents.html.twig @@ -0,0 +1,80 @@ +{%- include 'blocks/head.html.twig' with { title: pageTitle, cssFolderPath: cssFolderPath } %} + + +
+
+
{{ pageTitle }}
+
+
+ {%- include 'blocks/main-menu.html.twig' with { mainMenu: mainMenu } %} +
+
+ +
+ {%- include 'blocks/header.html.twig' with { + imagesFolderPath: imagesFolderPath, + methodsPath: methodsPath, + relativeToRootPath: relativeToRootPath + } %} + +
+

+ Оглавление +

+
+ {%- include 'blocks/table-of-contents-body.html.twig' with { + methods: tableOfContents.methods, + classes: tableOfContents.classes, + enums: tableOfContents.enums + } %} +
+ + {% if methods is not null %} +

+ Методы +

+ {% for method in methods %} +
+ {%- include 'blocks/method-body.html.twig' with { + method: method, + objectsLinks: objectsLinks, + showSandbox: false + } %} +
+ {% endfor %} + {% endif %} + + {% if classes is not null %} +

+ Классы +

+ {% for class in classes %} +
+ {%- include 'blocks/class-body.html.twig' with { + structure: class, + objectsLinks: objectsLinks + } %} +
+ {% endfor %} + {% endif %} + + {% if enums is not null %} +

+ Перечисления +

+ {% for enum in enums %} +
+ {%- include 'blocks/enum-body.html.twig' with { + structure: enum, + objectsLinks: objectsLinks + } %} +
+ {% endfor %} + {% endif %} +
+
+ +{%- include 'blocks/scripts.html.twig' with { jsFolderPath: jsFolderPath } %} + + + \ No newline at end of file diff --git a/Web-documentation/blocks/class-body.html.twig b/Web-documentation/blocks/class-body.html.twig new file mode 100644 index 0000000..4089328 --- /dev/null +++ b/Web-documentation/blocks/class-body.html.twig @@ -0,0 +1,22 @@ +

Описание

+

{{ structure.type.baseTypeName }} - {{ structure.description }}

+ +{%- include 'comment.html.twig' with { comment: structure.comment } %} + +

Структура данных

+
+
+
+
Название поля
+
Тип поля
+
Описание
+
Обязательность
+
+ {% for field in structure.allFieldsOrdered -%} + {%- include 'field-row.html.twig' with { + field: field, + objectsLinks: objectsLinks + } %} + {%- endfor %} +
+
\ No newline at end of file diff --git a/Web-documentation/blocks/enum-body.html.twig b/Web-documentation/blocks/enum-body.html.twig new file mode 100644 index 0000000..6c7997a --- /dev/null +++ b/Web-documentation/blocks/enum-body.html.twig @@ -0,0 +1,20 @@ +

Описание

+

{{ structure.name }} - {{ structure.description }}

+ +{%- include 'comment.html.twig' with { comment: structure.comment } %} + +

Возможные значения

+
+
+
+
Значения
+
Описание
+
+ {% for value in structure.values %} +
+
{{ value.value }}
+
{{ value.description }}
+
+ {% endfor %} +
+
\ No newline at end of file diff --git a/Web-documentation/blocks/main-menu.html.twig b/Web-documentation/blocks/main-menu.html.twig index 023edb6..73ac049 100644 --- a/Web-documentation/blocks/main-menu.html.twig +++ b/Web-documentation/blocks/main-menu.html.twig @@ -28,4 +28,8 @@
  • Оглавление
  • {% endif %} + {%- if mainMenu.allContents is not null %} +
  • Версия для печати
  • + {% endif %} + \ No newline at end of file diff --git a/Web-documentation/blocks/method-body.html.twig b/Web-documentation/blocks/method-body.html.twig new file mode 100644 index 0000000..7c0268d --- /dev/null +++ b/Web-documentation/blocks/method-body.html.twig @@ -0,0 +1,96 @@ +

    Метод

    +

    POST {{ method.url }}

    + +

    Описание

    +

    {{ method.description }}

    + +{%- include 'comment.html.twig' with { comment: method.comment } %} + +

    Параметры

    +{% if method.requestFields is not empty %} +
    +
    +
    +
    Название параметра
    +
    Тип параметра
    +
    Описание
    +
    Обязательность
    +
    + {% for field in method.requestFields -%} + {%- include 'field-row.html.twig' with { + field: field, + objectsLinks: objectsLinks + } %} + {%- endfor %} +
    + {% if default(showSandbox, true) %} + +
    +
    + {% for field in method.requestFields -%} + + {% endfor %} + + +
    +
    +
    + {% endif %} +
    +{% else %} +

    Параметры отсутствуют

    +{% endif %} + +

    Возможные ошибки

    +{% for value in method.errorsEnumeration.values -%} + {%- if value.value in method.errorsEnumeration.allowedValues %} +

    #Код {{ value.value }} — {{ value.description }}

    + {%- endif -%} +{%- endfor %} + +

    Результат

    +

    Объект следующей структуры:

    + +
    +
    +
    +
    Название поля
    +
    Тип поля
    +
    Описание
    +
    Обязательность
    +
    + {% for field in method.responseFields -%} + {%- include 'field-row.html.twig' with { + field: field, + objectsLinks: objectsLinks + } %} + {%- endfor %} +
    +
    \ No newline at end of file diff --git a/Web-documentation/blocks/table-of-contents-body.html.twig b/Web-documentation/blocks/table-of-contents-body.html.twig new file mode 100644 index 0000000..6e13ee3 --- /dev/null +++ b/Web-documentation/blocks/table-of-contents-body.html.twig @@ -0,0 +1,32 @@ +{%- if methods is not null %} +

    + Методы +

    + {% for methodsGroup in methods.items %} +

    + {{ methodsGroup.title }} +

    + {% for method in methodsGroup.items -%} +
  • {{ method.title }}
  • + {% endfor -%} + {% endfor %} + +{%- endif %} + +{%- if classes is not null %} +

    + Классы +

    + {% for class in classes.items -%} +
  • {{ class.title }}
  • + {% endfor %} +{% endif %} + +{%- if enums is not null %} +

    + Перечисления +

    + {% for enum in enums.items -%} +
  • {{ enum.title }}
  • + {% endfor %} +{%- endif %} \ No newline at end of file diff --git a/Web-documentation/js/main.js b/Web-documentation/js/main.js index b794b5c..52ed746 100644 --- a/Web-documentation/js/main.js +++ b/Web-documentation/js/main.js @@ -1,10 +1,50 @@ $(function () { $(document).ready(function () { + let sizes = [30, 70]; - window.Split(['.aside-left', '.aside-right'], { - sizes: [30, 70], - minSize: [200, 769] - }) + const splitSizesKey = 'split-sizes'; + + try { + const localStorageSizes = localStorage.getItem(splitSizesKey); + sizes = JSON.parse(localStorageSizes); + } catch (e) { + console.info("Unable to read split size from localStorage. Using defaults."); + } + + let split = window.Split(['.aside-left', '.aside-right'], { + sizes: sizes, + minSize: [200, 769], + onDragEnd: function () { + try { + sizes = split.getSizes(); + localStorage.setItem(splitSizesKey, JSON.stringify(sizes)); + } catch (e) { + // SecurityError (DOM Exception 18): The operation is insecure. + } + } + }); + + window.split1 = split; + + const beforePrint = function() { + split.collapse(0); + console.log('Functionality to run before printing.'); + }; + const afterPrint = function() { + split.setSizes(sizes); + console.log('Functionality to run after printing.'); + }; + + if (window.matchMedia) { + const mediaQueryList = window.matchMedia('print'); + mediaQueryList.addListener(function(mql) { + if (mql.matches) { + beforePrint(); + } else { + afterPrint(); + } + }); + } $('.part-example-response .text-response').css('height', $('.inputs').height() - 21); diff --git a/Web-documentation/methods.html.twig b/Web-documentation/methods.html.twig index 2902545..b1cd5b6 100644 --- a/Web-documentation/methods.html.twig +++ b/Web-documentation/methods.html.twig @@ -10,11 +10,11 @@ {% for menu in menus %} - {% include 'blocks/secondary-menu.html.twig' with { - menu: menu, - menuTitle: menu.title, - activeItemTypeName: name - } %} + {% include 'blocks/secondary-menu.html.twig' with { + menu: menu, + menuTitle: menu.title, + activeItemTypeName: name + } %} {% endfor %} @@ -30,97 +30,10 @@
    -

    Метод

    -

    POST {{ url }}

    - -

    Описание

    -

    {{ description }}

    - - {%- include 'blocks/comment.html.twig' with { comment: comment } %} - -

    Параметры

    -
    -
    -
    -
    Название параметра
    -
    Тип параметра
    -
    Описание
    -
    Обязательность
    -
    - {% for field in requestFields -%} - {%- include 'blocks/field-row.html.twig' with { - field: field, - objectsLinks: objectsLinks - } %} - {%- endfor %} -
    - -
    -
    - {% for field in requestFields -%} - - {% endfor %} - - -
    -
    -
    -
    - -

    Возможные ошибки

    - {% for value in errorsEnumeration.values -%} - {%- if value.value in errorsEnumeration.allowedValues %} -

    #Код {{ value.value }} — {{ value.description }}

    - {%- endif -%} - {%- endfor %} - -

    Результат

    -

    Объект следующей структуры:

    - -
    -
    -
    -
    Название поля
    -
    Тип поля
    -
    Описание
    -
    Обязательность
    -
    - {% for field in responseFields -%} - {%- include 'blocks/field-row.html.twig' with { - field: field, - objectsLinks: objectsLinks - } %} - {%- endfor %} -
    -
    - + {%- include 'blocks/method-body.html.twig' with { + method: method, + objectsLinks: objectsLinks + } %}
    diff --git a/Web-documentation/structure_enumeration.html.twig b/Web-documentation/structure_enumeration.html.twig index 21a7818..2fa217c 100644 --- a/Web-documentation/structure_enumeration.html.twig +++ b/Web-documentation/structure_enumeration.html.twig @@ -6,7 +6,7 @@
    {{ pageTitle }}
    - {%- include 'blocks/main-menu.html.twig' %} + {%- include 'blocks/main-menu.html.twig' with { mainMenu: mainMenu } %} {% include 'blocks/secondary-menu.html.twig' with { @@ -24,30 +24,14 @@
    - {%- include 'blocks/header.html.twig' with { imagesFolderPath: imagesFolderPath } %} + {%- include 'blocks/header.html.twig' with { + imagesFolderPath: imagesFolderPath, + relativeToRootPath: relativeToRootPath + } %}
    -

    Описание

    -

    {{ name }} - {{ description }}

    - - {%- include 'blocks/comment.html.twig' with { comment: comment } %} - -

    Возможные значения

    -
    -
    -
    -
    Значения
    -
    Описание
    -
    - {% for value in values %} -
    -
    {{ value.value }}
    -
    {{ value.description }}
    -
    - {% endfor %} -
    -
    + {%- include 'blocks/enum-body.html.twig' with { structure: structure } %}
    diff --git a/Web-documentation/structure_objects.html.twig b/Web-documentation/structure_objects.html.twig index 0622e7a..eb912b5 100644 --- a/Web-documentation/structure_objects.html.twig +++ b/Web-documentation/structure_objects.html.twig @@ -11,7 +11,8 @@ {% include 'blocks/secondary-menu.html.twig' with { menu: enumsMenu, - menuTitle: "Перечисления" + menuTitle: "Перечисления", + activeItemTypeName: name } %} {% include 'blocks/secondary-menu.html.twig' with { menu: classesMenu, @@ -25,34 +26,15 @@
    {%- include 'blocks/header.html.twig' with { imagesFolderPath: imagesFolderPath, - methodsPath: methodsPath, relativeToRootPath: relativeToRootPath } %}
    -

    Описание

    -

    {{ type.baseTypeName }} - {{ description }}

    - - {%- include 'blocks/comment.html.twig' with { comment: comment } %} - -

    Структура данных

    -
    -
    -
    -
    Название поля
    -
    Тип поля
    -
    Описание
    -
    Обязательность
    -
    - {% for field in allFieldsOrdered -%} - {%- include 'blocks/field-row.html.twig' with { - field: field, - objectsLinks: objectsLinks - } %} - {%- endfor %} -
    -
    + {%- include 'blocks/class-body.html.twig' with { + structure: structure, + objectsLinks: objectsLinks + } %}
    diff --git a/Web-documentation/table_of_contents.html.twig b/Web-documentation/table_of_contents.html.twig index ae547e8..f39053f 100644 --- a/Web-documentation/table_of_contents.html.twig +++ b/Web-documentation/table_of_contents.html.twig @@ -13,46 +13,16 @@
    {%- include 'blocks/header.html.twig' with { imagesFolderPath: imagesFolderPath, - methodsPath: methodsPath, relativeToRootPath: relativeToRootPath } %}
    - - {%- if tableOfContents.methods is not null %} -

    - Методы -

    - {% for methodsGroup in tableOfContents.methods.items %} -

    - {{ methodsGroup.title }} -

    - {% for method in methodsGroup.items -%} -
  • {{ method.title }}
  • - {% endfor -%} - {% endfor %} - - {%- endif %} - - {%- if tableOfContents.classes is not null %} -

    - Классы -

    - {% for class in tableOfContents.classes.items -%} -
  • {{ class.title }}
  • - {% endfor %} - {% endif %} - - {%- if tableOfContents.enums is not null %} -

    - Перечисления -

    - {% for enum in tableOfContents.enums.items -%} -
  • {{ enum.title }}
  • - {% endfor %} - {%- endif %} - + {%- include 'blocks/table-of-contents-body.html.twig' with { + methods: tableOfContents.methods, + classes: tableOfContents.classes, + enums: tableOfContents.enums + } %}