The legacy wiki pages are here for reference purposes only.
For up-to-date information make sure to check the documentation section.

Publishes a document by adding it to the umbraco.config file, prior to this the document should be marked published by calling Document.Publish(User u) on the document object.

Example

//...
using
 umbraco;
using umbraco.cms.businesslogic.web;
//...

//Create new DocumentObject
Document doc = new Document(id);
//Mark the document for publish under Admin account
doc.Publish(new User(0));
//Publish the document by Updating umbraco.config file
library.UpdateDocumentCache(doc.Id);
Our.umbraco.org is the community mothership for Umbraco, the open source asp.net cms. With a friendly forum for all your questions, a comprehensive documentation and a ton of packages from the community. This site is running Umbraco version 7.3.0-RC