Add entities and improve generate_entities script

Add entities parsed from apidoc inspection.

Also do some improvements for the `generate_entities` script.

Related to #915