add docs and example for custom publish function