From c897a8e4440884558673bc4d6e724ee240fd98a0 Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Thu, 20 Aug 2020 07:14:53 +0900 Subject: [PATCH] doc: Reorganize contributor doc Ussuri community goal "Project specific contributor and PTL docs" want us to use doc/source/contributor/contributing.rst as an entry point, but the current contributor/contributing.rst in horizon contains a lot of information. Before updating the file to satisfy the community goal criteria, this commit reorganize the contributor doc. It splits the existing contents in contributing.rst into pieces. Change-Id: I8aa9a310a99e0eed5a93ed040a02a2829ee09bf7 --- doc/source/contributor/contributing.rst | 584 +----------------- doc/source/contributor/index.rst | 2 +- .../contributor/policies/core-reviewers.rst | 65 ++ doc/source/contributor/policies/index.rst | 12 + .../supported-software.rst} | 10 +- doc/source/contributor/topics/code-style.rst | 430 +++++++++++++ doc/source/contributor/topics/index.rst | 3 + doc/source/contributor/topics/profiling.rst | 30 + .../contributor/topics/release-notes.rst | 56 ++ doc/source/install/system-requirements.rst | 2 +- 10 files changed, 604 insertions(+), 590 deletions(-) create mode 100644 doc/source/contributor/policies/core-reviewers.rst create mode 100644 doc/source/contributor/policies/index.rst rename doc/source/contributor/{policy.rst => policies/supported-software.rst} (93%) create mode 100644 doc/source/contributor/topics/code-style.rst create mode 100644 doc/source/contributor/topics/profiling.rst create mode 100644 doc/source/contributor/topics/release-notes.rst diff --git a/doc/source/contributor/contributing.rst b/doc/source/contributor/contributing.rst index 739f6e2e26..5cf4e51171 100644 --- a/doc/source/contributor/contributing.rst +++ b/doc/source/contributor/contributing.rst @@ -92,7 +92,7 @@ Once you've made your changes, there are a few things to do: * Make sure the unit tests and linting tasks pass by running ``tox`` * Take a look at your patch in API profiler, i.e. how it impacts the - performance. See `Profiling Pages`_. + performance. See :doc:`topics/profiling`. * Make sure your code is ready for translation: See :ref:`pseudo_translation`. * Make sure your code is up-to-date with the latest master: ``git pull --rebase`` @@ -104,37 +104,6 @@ If the review is approved, it is sent to Jenkins to verify the unit tests pass and it can be merged cleanly. Once Jenkins approves it, the change will be merged to the master repository and it's time to celebrate! -Profiling Pages ---------------- - -In the Ocata release of Horizon a new "OpenStack Profiler" panel was -introduced. Once it is enabled and all prerequisites are set up, you can see -which API calls Horizon actually makes when rendering a specific page. To -re-render the page while profiling it, you'll need to use the "Profile" -dropdown menu located in the top right corner of the screen. In order to -be able to use "Profile" menu, the following steps need to be completed: - -#. Enable the Developer dashboard by copying ``_9001_developer.py`` from - ``openstack_dashboard/contrib/developer/enabled/`` to - ``openstack_dashboard/local/enabled/``. -#. Copy - ``openstack_dashboard/local/local_settings.d/_9030_profiler_settings.py.example`` - to ``openstack_dashboard/local/local_settings.d/_9030_profiler_settings.py`` -#. Copy ``openstack_dashboard/contrib/developer/enabled/_9030_profiler.py`` to - ``openstack_dashboard/local/enabled/_9030_profiler.py``. -#. To support storing profiler data on server-side, MongoDB cluster needs to be - installed on your Devstack host (default configuration), see - `Installing MongoDB`_. Then, change the ``bindIp`` key in - ``/etc/mongod.conf`` to ``0.0.0.0`` and invoke - ``sudo service mongod restart``. -#. Collect and compress static assets with - ``python manage.py collectstatic -c`` and ``python manage.py compress`` -#. Restart the web server. -#. The "Profile" drop-down menu should appear in the top-right corner, you are - ready to profile your pages! - -.. _installing MongoDB: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/#install-mongodb-community-edition - Etiquette ========= @@ -156,554 +125,3 @@ The community's guidelines for etiquette are fairly simple: * Give credit where credit is due; if someone helps you substantially with a piece of code, it's polite (though not required) to thank them in your commit message. - -Code Style -========== - -As a project, Horizon adheres to code quality standards. - -Python ------- - -We follow PEP8_ for all our Python code, and use ``pep8.py`` (available -via the shortcut ``tox -e pep8``) to validate that our code -meets proper Python style guidelines. - -.. _PEP8: https://www.python.org/dev/peps/pep-0008/ - -Django ------- - -Additionally, we follow `Django's style guide`_ for templates, views, and -other miscellany. - -.. _Django's style guide: https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/ - -JavaScript ----------- - -The following standards are divided into required and recommended sections. -Our main goal in establishing these best practices is to have code that is -reliable, readable, and maintainable. - -Required -~~~~~~~~ - -**Reliable** - -* The code has to work on the stable and latest versions of Firefox, Chrome, - Safari, and Opera web browsers, and on Microsoft Internet Explorer 11 and - later. - -* If you turned compression off during development via ``COMPRESS_ENABLED = - False`` in local_settings.py, re-enable compression and test your code - before submitting. - -* Use ``===`` as opposed to ``==`` for equality checks. The ``==`` will do a - type cast before comparing, which can lead to unwanted results. - - .. note:: - - If typecasting is desired, explicit casting is preferred to keep the - meaning of your code clear. - -* Keep document reflows to a minimum. DOM manipulation is expensive, and can - become a performance issue. If you are accessing the DOM, make sure that you - are doing it in the most optimized way. One example is to build up a document - fragment and then append the fragment to the DOM in one pass instead of doing - multiple smaller DOM updates. - -* Use "strict", enclosing each JavaScript file inside a self-executing - function. The self-executing function keeps the strict scoped to the file, - so its variables and methods are not exposed to other JavaScript files in - the product. - - .. Note :: - Using strict will throw exceptions for common coding errors, like - accessing global vars, that normally are not flagged. - - Example: - :: - - (function(){ - 'use strict'; - // code... - })(); - -* Use ``forEach`` | ``each`` when looping whenever possible. AngularJS and - jQuery both provide for each loops that provide both iteration and scope. - - AngularJS: - :: - - angular.forEach(objectToIterateOver, function(value, key) { - // loop logic - }); - - jQuery: - :: - - $.each(objectToIterateOver, function(key, value) { - // loop logic - }); - -* Do not put variables or functions in the global namespace. There are several - reasons why globals are bad, one being that all JavaScript included in an - application runs in the same scope. The issue with that is if another script - has the same method or variable names they overwrite each other. -* Always put ``var`` in front of your variables. Not putting ``var`` in front - of a variable puts that variable into the global space, see above. -* Do not use ``eval( )``. The eval (expression) evaluates the expression - passed to it. This can open up your code to security vulnerabilities and - other issues. -* Do not use '``with`` object {code}'. The ``with`` statement is used to access - properties of an object. The issue with ``with`` is that its execution is not - consistent, so by reading the statement in the code it is not always clear - how it is being used. - -**Readable & Maintainable** - -* Give meaningful names to methods and variables. -* Avoid excessive nesting. -* Avoid HTML and CSS in JS code. HTML and CSS belong in templates and - stylesheets respectively. For example: - - * In our HTML files, we should focus on layout. - - 1. Reduce the small/random ``