Apply the new naming convention to remaining directories.
See original GitHub issueThe new naming convention needs to be applied to the remaining directories.
-
services/
@xlogix #6975 -
extensions/
@RafayGhafoor #7360 -
domain/
@Jethet -
expressions/
- @rt4914 -
directives/
- @rt4914 (#7215) -
base_components/
- @rt4914
The naming follows a general pattern:
-
The filename is divided into three parts (four for spec files). The first part is the name of the functionality, the second part is the type of functionality and the third part is the file extension. The third part in case of spec files become the word “spec” and the extension becomes the fourth part.
-
The different parts of the filename are joined by periods.
-
If the first part of the name has multiple words then the words are joined by kebab-case, with all the letters being small.
-
For eg if there is a directive file which houses a directive named stateResponses. Then the name of the file would be state-responses.directive.ts
Types of functionality.
-
Directives: A directive’s name must end with “.directive.ts” For example, if the name of a directive is ‘stateResponses’ then the name of the file must be “state-responses.directive.ts”.
-
Controllers: A controller’s name must end with “.controller.ts” For example, if the name of a directive is ‘StoryEditor’ then the name of the file must be “story-editor.controller.ts”.
-
Filters: A filter’s name must end with “.filter.ts” For example, if the name of a filter is ‘formatTimer’ then the name of the file must be “format-timer.filter.ts”.
-
Services: A service’s name must end with “.service.ts” For example, if the name of a service is ‘ExplorationDataService’ then the name of the file must be “exploration-data.service.ts”.
-
Constants: The constants of a page are to be kept in a single file. The file should be named name-of-the-page.constants.ts. Any new constant that needs to be added should be added to this file only and this constants.ts file should be required in the file which uses the constant.
-
HTML files: There are three types of HTML files:-
-
Mainpage: These are the pages which act as a starting point of the page. These pages are directly called from the backend. The names of these HTML files must end with “.mainpage.html”. For example, the main page of the exploration editor page would be named exploration-editor-page.mainpage.html.
-
Directive: These are the HTML files which are served by the directive files. These are the HTML files that appear in the ‘templateUrl’ of the directive. These must have their names ending with “.directive.html”. For example, the progress nav directive would be named progress-nav.directive.html.
-
Template: These are the shared HTML files which are required by various other functions like modals, jinja templating, etc. These names are to end with “.template.html”
-
-
Script files: These are the TS files which are for the sole purpose of importing the required TS files for the HTML file. Such files are to end with “.scripts.ts”. For example if a file get-started.mainpage.html needs a script file then the file would be named “get-started.scripts.ts”
Note: The root directory for the frontend file is located here: oppia/core/templates/dev/head
Issue Analytics
- State:
- Created 4 years ago
- Comments:40 (38 by maintainers)
Top GitHub Comments
@RafayGhafoor, I found that your PR for the
/extension
part of this issue is already merged, so I’ve updated the issue description accordingly. Thanks! 😃Yes sure.