This is easier if one uses a simple game template, like TheouAegis's CV NES-looking template, as it would let us use just one type of 'block' as a tile.
The graphic below is set to the usual H16xV12 tile template (16 tiles wide, 12 tiles tall screen size).
It would be something like this:

You have these 'room containers', comprised of a screen in a room, each.
At the start of each stage, as Simon/Trevor/Grant/anyone is 'walking across the map graphic', you get a description of what the stage will be like.
"Alchemy Laboratory" "Underground Caverns", etc.
While it's doing this, it's calculating the stage based on the following rules:
1. The difficulty you set at the beginning of the game presets the range of 'screens' the player must traverse. A difficulty level that's high would yield a longer stage with more perils, etc. An easy difficulty would be something like 32 rooms or so, while a tougher one would be something like 64.
2. Note the map graphics above: Every green Entry/Exit point in a screen must lead to another Entry/Exit point.
3. Every screen has an 'edge' on its walls if it has walls, (in RED). The edge of every screen must touch an edge of the adjacent screen. No naked edges are allowed.
4. If the screen's side has no edge, its adjacent screen must also have no edge on the side that's touching that edge.
Following these rules, one should be able to use the room containers. Since no naked edges are allowed, this automatically will create:
-hallways
-towers
-nooks (1-screen rooms)
-alcoves (1-screen rooms with more than one exit)
-large rooms (if one uses the all-blue air room)
Once the membrane (the edges of every screen, when stitched together) of a room has been decided, the game will fill the area with various pre-determined room contents. The rules for room contents are as follows:
1. if a predetermined template can be used to fill an entire area (say, if someone designed content for a h2xv4 'tower'), it is noted. If there are more configurations, it picks one at random.
OR
2. it may fill the room with 1-screen room content templates (in my diagram I only made 3, but a good level designer could conceivably make up hundreds).
Some extra rules to spice things up:
1. If a room is an alcove, it may contain a tough enemy, or a healing font. There are no save points in this type of game, just check points upon stage clear.
2 If a room has a 'floor', depending on the theme of the stage, it may have spikes, water, or lava in it.
3. every stage needs three 'special rooms' that are always in the stage, regardless of the randomly-generated rooms. This means that, no matter how one might generate the "Underground Caverns", there WILL be a room with the Waterfall in it. If one is on the "Clock Tower", no matter how the stage is laid out, there WILL be one "Pendulum Chamber" or "Gear Room". This ensures that there is some special elements in the stages, rather than them just being coookiecutouts.
4. obviously, every tileset would have to be made to accomodate every stage, so common tilesets have to be built.
5. every stage has the boss room in the same location, and a connector to the 'exit' on the room afterwards.
6. your character will need to have the abilities to traverse the stage. This means that your character is going to need doublejump or walljump or flying powers to get through, as some stages may not have the footholds to get you everywhere. However, they should be programmed such that every combination of container and content work together. You will never start the stage and be walled off.