Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
coding_standards.doctree187 linesDownload Raw Back to .doctrees
1���>�sphinx.addnodes��document���)��}�(�	rawsource����children�]�(�docutils.nodes��target���)��}�(h�.. _coding_standards:�h]��2attributes�}�(�ids�]��classes�]��names�]��dupnames�]��backrefs�]��refid��coding-standards�u�tagname�h3�line�K�parent�h�	_document�h�source��kD:\a\pgadmin-packaging-foundation\pgadmin-packaging-foundation\pgadmin4-8.6\docs\en_US\coding_standards.rst�ubh	�section���)��}�(hhh]�(h	�title���)��}�(h�`Coding Standards`:index:�h]�(h�index���)��}�(hhh]�h}�(h]�h]�h]�h]�h]��entries�]�(�single��Coding Standards��index-0�hNt�auhh/h"h#hKh h+ubh)��}�(hhh]�h}�(h]�h>ah]�h]�h]�h]�uhh4h h+ubh	�Text����Coding Standards�����}�(h h+h!hh"NhNubeh}�(h]�h]�h]�h]�h]�uhh)h h&h!hh"h#hKubh	�	paragraph���)��}�(h�ipgAdmin uses multiple technologies and multiple languages, each of which have5their own coding standards.�h]�hJ�ipgAdmin uses multiple technologies and multiple languages, each of which have6their own coding standards.�����}�(h hWh!hh"NhNubah}�(h]�h]�h]�h]�h]�uhhUh"h#hKh h&h!hubh%)��}�(hhh]�(h*)��}�(h�General�h]�hJ�General�����}�(h hhh!hh"NhNubah}�(h]�h]�h]�h]�h]�uhh)h heh!hh"h#hKubhV)��}�(hXUIn all languages, indentations should be made with 4 spaces, and excessively long7lines wrapped where appropriate to ensure they can be read on smaller displays8(80 characters is used in many places, but this is not a required maximum size9as it's quite wasteful on modern displays). Typically lines should not be longer10than 120 characters.�h]�hJXWIn all languages, indentations should be made with 4 spaces, and excessively long11lines wrapped where appropriate to ensure they can be read on smaller displays12(80 characters is used in many places, but this is not a required maximum size13as it’s quite wasteful on modern displays). Typically lines should not be longer14than 120 characters.�����}�(h hvh!hh"NhNubah}�(h]�h]�h]�h]�h]�uhhUh"h#hK
h heh!hubhV)��}�(h��Comments should be included in all code where required to explain its15purpose or how it works if not obvious from a quick review of the code itself.�h]�hJ��Comments should be included in all code where required to explain its16purpose or how it works if not obvious from a quick review of the code itself.�����}�(h h�h!hh"NhNubah}�(h]�h]�h]�h]�h]�uhhUh"h#hKh heh!hubeh}�(h]��general�ah]�h]��general�ah]�h]�uhh$h h&h!hh"h#hKubh%)��}�(hhh]�(h*)��}�(h�CSS 3�h]�hJ�CSS 3�����}�(h h�h!hh"NhNubah}�(h]�h]�h]�h]�h]�uhh)h h�h!hh"h#hKubhV)��}�(h�?CSS3 is used for styling and layout throughout the application.�h]�hJ�?CSS3 is used for styling and layout throughout the application.�����}�(h h�h!hh"NhNubah}�(h]�h]�h]�h]�h]�uhhUh"h#hKh h�h!hubhV)��}�(h��Most custom styling comes from individual modules which may advertise static17stylesheets to be included in the module that is loading them via hooks.�h]�hJ��Most custom styling comes from individual modules which may advertise static18stylesheets to be included in the module that is loading them via hooks.�����}�(h h�h!hh"NhNubah}�(h]�h]�h]�h]�h]�uhhUh"h#hKh h�h!hubhV)��}�(h��Styling overrides (for example, to alter the look and feel) will19typically be found in the **overrides.css** file in the main static file20directory for the application.�h]�(hJ�[Styling overrides (for example, to alter the look and feel) will21typically be found in the �����}�(h h�h!hh"NhNubh	�strong���)��}�(h�**overrides.css**�h]�hJ�
overrides.css�����}�(h h�h!hh"NhNubah}�(h]�h]�h]�h]�h]�uhh�h h�ubhJ�< file in the main static file22directory for the application.�����}�(h h�h!hh"NhNubeh}�(h]�h]�h]�h]�h]�uhhUh"h#hKh h�h!hubhV)��}�(h��Styling should never be applied inline in HTML, always through an external23stylesheet, which should contain comments as appropriate to explain the usage24or purpose for the style.�h]�hJ��Styling should never be applied inline in HTML, always through an external25stylesheet, which should contain comments as appropriate to explain the usage26or purpose for the style.�����}�(h h�h!hh"NhNubah}�(h]�h]�h]�h]�h]�uhhUh"h#hK"h h�h!hubhV)��}�(h�>Styles should be specified clearly, one per line. For example:�h]�hJ�>Styles should be specified clearly, one per line. For example:�����}�(h h�h!hh"NhNubah}�(h]�h]�h]�h]�h]�uhhUh"h#hK&h h�h!hubh	�
literal_block���)��}�(h��/* iFrames should have no border */27iframe {28    border-width: 0;29}30 31/* Ensure the codemirror editor displays full height gutters when resized */32.CodeMirror, .CodeMirror-gutters {33    height: 100% !important;34}�h]�hJ��/* iFrames should have no border */35iframe {36    border-width: 0;37}38 39/* Ensure the codemirror editor displays full height gutters when resized */40.CodeMirror, .CodeMirror-gutters {41    height: 100% !important;42}�����}�h jsbah}�(h]�h]�h]�h]�h]��	xml:space��preserve��force���language��css��highlight_args�}�uhjh"h#hK(h h�h!hubhV)��}�(h�'All stylesheets must be CSS3 compliant.�h]�hJ�'All stylesheets must be CSS3 compliant.�����}�(h jh!hh"NhNubah}�(h]�h]�h]�h]�h]�uhhUh"h#hK4h h�h!hubeh}�(h]��css-3�ah]�h]��css 3�ah]�h]�uhh$h h&h!hh"h#hKubh%)��}�(hhh]�(h*)��}�(h�HTML 5�h]�hJ�HTML 5�����}�(h j5h!hh"NhNubah}�(h]�h]�h]�h]�h]�uhh)h j2h!hh"h#hK7ubhV)��}�(h��HTML 5 is used for page structure throughout the application, in most cases43being rendered from templates by the Jinja2 template engine in Flask.�h]�hJ��HTML 5 is used for page structure throughout the application, in most cases44being rendered from templates by the Jinja2 template engine in Flask.�����}�(h jCh!hh"NhNubah}�(h]�h]�h]�h]�h]�uhhUh"h#hK9h j2h!hubhV)��}�(h�"All HTML must be HTML 5 compliant.�h]�hJ�"All HTML must be HTML 5 compliant.�����}�(h jQh!hh"NhNubah}�(h]�h]�h]�h]�h]�uhhUh"h#hK<h j2h!hubeh}�(h]��html-5�ah]�h]��html 5�ah]�h]�uhh$h h&h!hh"h#hK7ubh%)��}�(hhh]�(h*)��}�(h�45Javascript�h]�hJ�46Javascript�����}�(h jjh!hh"NhNubah}�(h]�h]�h]�h]�h]�uhh)h jgh!hh"h#hK?ubhV)��}�(hXClient-side code is written in Javascript using ReactJS and various plugins.47Whilst much of the code is rendered from static files, there is also code that48is rendered from templates using Jinja2 (often to inject the users settings) or49constructed on the fly from module hooks.�h]�hJXClient-side code is written in Javascript using ReactJS and various plugins.50Whilst much of the code is rendered from static files, there is also code that51is rendered from templates using Jinja2 (often to inject the users settings) or52constructed on the fly from module hooks.�����}�(h jxh!hh"NhNubah}�(h]�h]�h]�h]�h]�uhhUh"h#hKAh jgh!hubhV)��}�(h�]A typical Javascript function might be formatted like this (this snipped is from53a template):�h]�hJ�]A typical Javascript function might be formatted like this (this snipped is from54a template):�����}�(h j�h!hh"NhNubah}�(h]�h]�h]�h]�h]�uhhUh"h#hKFh jgh!hubj)��}�(hX�// Delete a server group55function delete_server_group(item) {56    alertify.confirm(57        'Delete server group?',58        'Are you sure you wish to delete the server group "{0}"?'.replace('{0}', tree.getLabel(item)),59        function() {60            var id = tree.getId(item)61            $.post("{{ url_for('NODE-server-group.delete') }}", { id: id })62                .done(function(data) {63                    if (data.success == 0) {64                        report_error(data.errormsg, data.info);65                    } else {66                        var next = tree.next(item);67                        var prev = tree.prev(item);68                        tree.remove(item);69                        if (next.length) {70                            tree.select(next);71                        } else if (prev.length) {72                            tree.select(prev);73                        }74                    }75                }76            )77        },78        null79    )80}�h]�hJX�// Delete a server group81function delete_server_group(item) {82    alertify.confirm(83        'Delete server group?',84        'Are you sure you wish to delete the server group "{0}"?'.replace('{0}', tree.getLabel(item)),85        function() {86            var id = tree.getId(item)87            $.post("{{ url_for('NODE-server-group.delete') }}", { id: id })88                .done(function(data) {89                    if (data.success == 0) {90                        report_error(data.errormsg, data.info);91                    } else {92                        var next = tree.next(item);93                        var prev = tree.prev(item);94                        tree.remove(item);95                        if (next.length) {96                            tree.select(next);97                        } else if (prev.length) {98                            tree.select(prev);99                        }100                    }101                }102            )103        },104        null105    )106}�����}�h j�sbah}�(h]�h]�h]�h]�h]�jjj�j�107javascript�j}�uhjh"h#hKIh jgh!hubhV)��}�(h��Note the use of a descriptive function name, using the underscore character to108separate words in all lower case, and short but descriptive lower case variable109names.�h]�hJ��Note the use of a descriptive function name, using the underscore character to110separate words in all lower case, and short but descriptive lower case variable111names.�����}�(h j�h!hh"NhNubah}�(h]�h]�h]�h]�h]�uhhUh"h#hKgh jgh!hubh	�note���)��}�(h�fFrom version 3.0 onwards, new or refactored code should be written using112ES6 features and conventions.�h]�hV)��}�(h�fFrom version 3.0 onwards, new or refactored code should be written using113ES6 features and conventions.�h]�hJ�fFrom version 3.0 onwards, new or refactored code should be written using114ES6 features and conventions.�����}�(h j�h!hh"NhNubah}�(h]�h]�h]�h]�h]�uhhUh"h#hKkh j�ubah}�(h]�h]�h]�h]�h]�uhj�h"h#hKkh jgh!hubeh}�(h]��115javascript�ah]�h]��116javascript�ah]�h]�uhh$h h&h!hh"h#hK?ubh%)��}�(hhh]�(h*)��}�(h�Python�h]�hJ�Python�����}�(h j�h!hh"NhNubah}�(h]�h]�h]�h]�h]�uhh)h j�h!hh"h#hKoubhV)��}�(hX8Python is used for the backend web server. All code must be compatible with117Python 2.7 and should include PyDoc comments whilst following the official118Python coding standards defined in119`PEP 8 <https://www.python.org/dev/peps/pep-0008/>`_. An example function along120with the required file header is shown below::�h]�(hJ��Python is used for the backend web server. All code must be compatible with121Python 2.7 and should include PyDoc comments whilst following the official122Python coding standards defined in123�����}�(h j�h!hh"NhNubh	�	reference���)��}�(h�4`PEP 8 <https://www.python.org/dev/peps/pep-0008/>`_�h]�hJ�PEP 8�����}�(h j�h!hh"NhNubah}�(h]�h]�h]�h]�h]��name��PEP 8��refuri��)https://www.python.org/dev/peps/pep-0008/�uhj�h j�ubh)��}�(h�, <https://www.python.org/dev/peps/pep-0008/>�h]�h}�(h]��pep-8�ah]�h]��pep 8�ah]�h]��refuri�juhh124�125referenced�Kh j�ubhJ�I. An example function along126with the required file header is shown below:�����}�(h j�h!hh"NhNubeh}�(h]�h]�h]�h]�h]�uhhUh"h#hKqh j�h!hubj)��}�(hX\##########################################################################127#128# pgAdmin 4 - PostgreSQL Tools129#130# Copyright (C) 2013 - 2024, The pgAdmin Development Team131# This software is released under the PostgreSQL Licence132#133##########################################################################134 135"""Integration hooks for server groups."""136 137from flask import render_template, url_for138from flask.ext.security import current_user139 140from pgadmin.settings.settings_model import db, ServerGroup141 142def get_nodes():143    """Return a JSON document listing the server groups for the user"""144    groups = ServerGroup.query.filter_by(user_id=current_user.id)145 146    value = ''147    for group in groups:148        value += '{"id":%d,"label":"%s","icon":"icon-server-group","inode":true},' \149                 % (group.id, group.name)150 151    value = value[:-1]152 153    return value�h]�hJX\##########################################################################154#155# pgAdmin 4 - PostgreSQL Tools156#157# Copyright (C) 2013 - 2024, The pgAdmin Development Team158# This software is released under the PostgreSQL Licence159#160##########################################################################161 162"""Integration hooks for server groups."""163 164from flask import render_template, url_for165from flask.ext.security import current_user166 167from pgadmin.settings.settings_model import db, ServerGroup168 169def get_nodes():170    """Return a JSON document listing the server groups for the user"""171    groups = ServerGroup.query.filter_by(user_id=current_user.id)172 173    value = ''174    for group in groups:175        value += '{"id":%d,"label":"%s","icon":"icon-server-group","inode":true},' \176                 % (group.id, group.name)177 178    value = value[:-1]179 180    return value�����}�h jsbah}�(h]�h]�h]�h]�h]�jjuhjh"h#hKwh j�h!hubeh}�(h]��python�ah]�h]��python�ah]�h]�uhh$h h&h!hh"h#hKoubeh}�(h]�(h�id1�eh]�h]�(�coding standards��coding_standards�eh]�h]�uhh$h hh!hh"h#hK�expect_referenced_by_name�}�j5hs�expect_referenced_by_id�}�hhsubeh}�(h]�h]�h]�h]�h]��source�h#�translation_progress�}�(�total�K�181translated�Kuuhh�current_source�N�current_line�N�settings��docutils.frontend��Values���)��}�(�output�Nh)N�	generator�N�	datestamp�N�root_prefix��/��source_link�N�182source_url�N�
toc_backlinks��entry��footnote_backlinks���
sectnum_xform���strip_comments�N�strip_elements_with_classes�N�
strip_classes�N�report_level�K�183halt_level�K�exit_status_level�K�debug�N�warning_stream�N�	traceback���input_encoding��	utf-8-sig��input_encoding_error_handler��strict��output_encoding��utf-8��output_encoding_error_handler�jf�error_encoding��cp1252��error_encoding_error_handler��backslashreplace��
language_code��en��record_dependencies�N�config�N�	id_prefix�h�auto_id_prefix��id��
dump_settings�N�dump_internals�N�dump_transforms�N�dump_pseudo_xml�N�expose_internals�N�strict_visitor�N�_disable_config�N�_source�h#�_destination�N�
_config_files�]��file_insertion_enabled���raw_enabled�K�line_length_limit�M'�pep_references�N�pep_base_url��https://peps.python.org/��pep_file_url_template��pep-%04d��rfc_references�N�rfc_base_url��&https://datatracker.ietf.org/doc/html/��	tab_width�K�trim_footnote_reference_space���syntax_highlight��long��smart_quotes���smartquotes_locales�]��character_level_inline_markup���doctitle_xform���
docinfo_xform���sectsubtitle_xform���
image_loading��link��embed_stylesheet���cloak_email_addresses���section_self_link���env�Nub�reporter�N�indirect_targets�]��substitution_defs�}��substitution_names�}��refnames�}��refids�}�h]�has�nameids�}�(j5hj4j1h�h�j/j,jdjaj�j�j,j)j184ju�	nametypes�}�(j5�j4�h��j/�jd�j��j,�j185�uh}�(hh&j1h&h�hej,h�jaj2j�jgj)j�jju�
footnote_refs�}��
citation_refs�}��
autofootnotes�]��autofootnote_refs�]��symbol_footnotes�]��symbol_footnote_refs�]��	footnotes�]��	citations�]��autofootnote_start�K�symbol_footnote_start�K�186id_counter��collections��Counter���}�jtKs��R��parse_messages�]��transform_messages�]�(h	�system_message���)��}�(hhh]�hV)��}�(hhh]�hJ�6Hyperlink target "coding-standards" is not referenced.�����}�h j�sbah}�(h]�h]�h]�h]�h]�uhhUh j�ubah}�(h]�h]�h]�h]�h]��level�K�type��INFO��source�h#�line�Kuhj�ubj�)��}�(hhh]�hV)��}�(hhh]�hJ�-Hyperlink target "index-0" is not referenced.�����}�h j�sbah}�(h]�h]�h]�h]�h]�uhhUh j�ubah}�(h]�h]�h]�h]�h]��level�K�type�j��source�h#�line�Kuhj�ube�transformer�N�include_log�]��187decoration�Nh!hub.
codekingpro/portable-devtools · Team Ai