It generates .did. files for example_backend and example_frontend, but does not generate .did. files for these canisters that are created by example_backend from actor classes. How to generate these .did. files?
I would guess you have to make the Motoko compiler do it for you. If you put the canister that your backend is deploying in a dfx project and dfx build it, then you’ll end up with the .did files. If you don’t want to go that route I guess you have to build the moc invocation yourself. You can find moc in the folder that dfx cache show points to, and IIRC if you build with verbose mode (-vv) you’ll get the moc invocations printed
Here’s an example of a remote canister. The intention behind the feature is that you can say that on certain networks you don’t want to deploy that canister. In this example, you only want to install the ledger if you’re running locally since there is no pre-installed ledger. On mainnet, you of course want to use the real ledger, so you don’t deploy your own
You recommend to use a remote canister for .did. generation. But an example of remote canister, that you pointed, refers to an already generated .did. file rather than generates it:
Are you sure dfx does not build the .did files? For me dfx builds the .did file also for an actor class.
Not sure which commands you have tried. Maybe dfx generate? That command creates the .did file for me. With your dfx.json it would be in src/declarations/backend_example/backend_example.did. The only difference with an actor class is that there are service arguments, i.e. in the line service : (...) -> the part (...) is non-empty. I would be interested in why it doesn’t do that for you.
Anyway, if dfx generate doesn’t work then another way is to use dfx build. That command does not deploy the canister. But it does create a canister id (an empty canister), i.e. it still needs a replica (dfx start) running in the background. So what you are looking for is dfx build --check. With the --check option it does not even create a canister id, hence you don’t need a replica running in the background. It builds .did and .wasm in .dfx/local/canisters/example_backend/. You can run dfx build --check example_backend to only build that one canister and not all that are defined in dfx.json.