fix null context while generate document