Cleanup apidoc and hackingdoc commands to use ctx.top_dir and ctx.out_dir

This should be cleaner and safer than using '../' mixed with os.chdir().