use same code for making refdoc as for schema