From 61eae879d4164c2eab3e7e8a78e47a6e3f9ff61a Mon Sep 17 00:00:00 2001 From: ganfra Date: Fri, 24 Mar 2023 17:24:06 +0100 Subject: [PATCH] Share the template files and update documentation about it. --- docs/_developer_onboarding.md | 38 ++++++++++++++++++++++++++--- tools/templates/FeatureModule.json | 1 + tools/templates/file_templates.zip | Bin 0 -> 834 bytes 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 tools/templates/FeatureModule.json create mode 100644 tools/templates/file_templates.zip diff --git a/docs/_developer_onboarding.md b/docs/_developer_onboarding.md index a526e0de33..b32d176a45 100644 --- a/docs/_developer_onboarding.md +++ b/docs/_developer_onboarding.md @@ -269,10 +269,42 @@ Here are the main points: #### Template and naming -There is a template module to easily start a new feature. When creating a new module, you can just copy paste the template. It is -located [here](../features/template). +This documentation provides you with the steps to install and use the AS plugin for generating modules in your project. +The plugin and templates will help you quickly create new features with a standardized structure. -For the naming rules, please follow what is being currently used in the template module. +##### A. Installation + +Follow these steps to install and configure the plugin and templates: + +1. Install the AS plugin for generating modules : + [Generate Module from Template](https://plugins.jetbrains.com/plugin/13586-generate-module-from-template) +2. Import file templates in AS : + - Navigate to File/Manage IDE Settings/Import Settings + - Pick the `tools/templates/file_templates.zip` files + - Click on OK +3. Configure generate-module-from-template plugin : + - Navigate to AS/Settings/Tools/Module Template Settings + - Click on + / Import From File + - Pick the `tools/templates/FeatureModule.json` + +Everything should be ready to use. + +##### B. Usage + +Example for a new feature called RoomDetails: + +1. Right-click on the features package and click on Create Module from Template +2. Fill the 2 text fields like so: + - MODULE_NAME = roomdetails + - FEATURE_NAME = RoomDetails +3. Click on Next +4. Verify that the structure looks ok and click on Finish +5. The modules api/impl should be created under `features/roomdetails` directory. +6. Sync project with Gradle so the modules are recognized (no need to add them to settings.gradle). +7. You can now add more Presentation classes (Events, State, StateProvider, View, Presenter) in the impl module with the `Template Presentation Classes`. + To use it, just right click on the package where you want to generate classes, and click on `Template Presentation Classes`. + Fill the text field with the base name of the classes, ie `RootRoomDetails` in the `root` package. + Note that naming of files and classes is important, since those names are used to set up code coverage rules. For instance, presenters MUST have a suffix `Presenter`,states MUST have a suffix `State`, etc. Also we want to have a common naming along all the modules. diff --git a/tools/templates/FeatureModule.json b/tools/templates/FeatureModule.json new file mode 100644 index 0000000000..9453a2b27b --- /dev/null +++ b/tools/templates/FeatureModule.json @@ -0,0 +1 @@ +{"template":{"name":"","isDir":true,"placeholders":{"MODULE_NAME":"","FEATURE_NAME":"","BUILD_GRADLE_API":"build.gradle.kts","BUILD_GRADLE_IMPL":"build.gradle.kts"},"fileTemplates":{"${FEATURE_NAME}EntryPoint":"Template Module Feature Entry Point API","Default${FEATURE_NAME}EntryPoint":"Template Module Feature Entry Point Flow Impl","${BUILD_GRADLE_API}":"Template Module Feature Build Gradle API","${BUILD_GRADLE_IMPL}":"Template Module Feature Build Gradle Impl","${FEATURE_NAME}FlowNode":"Template Module Feature Node Flow Impl"},"realChildren":[{"name":"${MODULE_NAME}","isDir":true,"realChildren":[{"name":"api","isDir":true,"realChildren":[{"name":"src","isDir":true,"realChildren":[{"name":"main","isDir":true,"realChildren":[{"name":"kotlin","isDir":true,"realChildren":[{"name":"io","isDir":true,"realChildren":[{"name":"element","isDir":true,"realChildren":[{"name":"android","isDir":true,"realChildren":[{"name":"features","isDir":true,"realChildren":[{"name":"${MODULE_NAME}","isDir":true,"realChildren":[{"name":"api","isDir":true,"realChildren":[{"name":"${FEATURE_NAME}EntryPoint","isDir":false,"placeholders":{},"fileTemplates":{},"realChildren":[]}]}]}]}]}]}]}]}]}]},{"name":"${BUILD_GRADLE_API}","isDir":false,"placeholders":{},"fileTemplates":{},"realChildren":[]}]},{"name":"impl","isDir":true,"realChildren":[{"name":"src","isDir":true,"realChildren":[{"name":"main","isDir":true,"realChildren":[{"name":"kotlin","isDir":true,"realChildren":[{"name":"io","isDir":true,"realChildren":[{"name":"element","isDir":true,"realChildren":[{"name":"android","isDir":true,"realChildren":[{"name":"features","isDir":true,"realChildren":[{"name":"${MODULE_NAME}","isDir":true,"realChildren":[{"name":"impl","isDir":true,"realChildren":[{"name":"Default${FEATURE_NAME}EntryPoint","isDir":false,"placeholders":{},"fileTemplates":{},"realChildren":[]},{"name":"${FEATURE_NAME}FlowNode","isDir":false,"placeholders":{},"fileTemplates":{},"realChildren":[]}]}]}]}]}]}]}]}]},{"name":"test","isDir":true,"realChildren":[{"name":"kotlin","isDir":true,"realChildren":[{"name":"element","isDir":true,"realChildren":[{"name":"android","isDir":true,"realChildren":[{"name":"features","isDir":true,"realChildren":[{"name":"${MODULE_NAME}","isDir":true,"realChildren":[{"name":"impl","isDir":true,"realChildren":[]}]}]}]}]}]}]}]},{"name":"${BUILD_GRADLE_IMPL}","isDir":false,"placeholders":{},"fileTemplates":{},"realChildren":[]}]}]}]},"language":"java","templateName":"FeatureModule","lowercaseDir":true,"capitalizeFile":false,"packageNameToDir":false} \ No newline at end of file diff --git a/tools/templates/file_templates.zip b/tools/templates/file_templates.zip new file mode 100644 index 0000000000000000000000000000000000000000..da6fcbec24b7df6904d960e0a62a2aa86f7260e2 GIT binary patch literal 834 zcmWIWW@Zs#;Nak3aA>LsV?Y8*Kz4pXNoIatv3^=+PO4r>YHmSJVo9oAacW6PW?p)+ zUPW%s*{S~CM+^jxzW=S+_F!x8|Gt+^9^apB+VChe$@uDq%%Dj(wL0$KU30sGT|467 zH!I`(d;FgcaopVI7Cvdq=F_YVD`GBNbx%8Rij6yL-y?+*dvhl|HguWJpS;7&h=pgu`wmCh+D(tYoP7Q3)v}t` z=@*SZL|EVV(31FRYhN_Fw1|NfYYrH;@4ld4)A8@Fl$_1#LCFPaGH&QApmEf@&W@jGq1QLF()TA zMX#iyB(%qn?~nnH>vx%BPAkk`9JtlE*QnRiM^;^8d61>;)QE)YOZESICI1@59^O*D z&MIv2hAT`HP4>=Q=;^=aLCCBH_1llk`^_6LH~MbC;){HpQ+W2?S}$arr}6xuiG$_6 zV;aW#q0j4oe|?j2`r$s7%S8Kx7TT&aWIzK$lSW}X|FhIBQ>-6RY%RVrId~wwM zh+H?&jfa64dP`W||gi{&1dC1NL1t|iA0;2#WfI(Wh7;yUop;elRps!egk;}lq420K!bQn+r G0|NkrW+b2h literal 0 HcmV?d00001