Fix RuntimeError with numbered circular toctree
Mark master_doc as assigned numbers
Optimize marking docnames as assigned
Merged in tk0miya/sphinx (pull request #273)

Fix RuntimeError with numbered circular toctree. Closes #1536