If I use the $(document).ready() handler from within a function, will it still guarantee that the code inside it will only be run if the document is ready, even
Yes.
From the jQuery ready function source.
// Catch cases where $(document).ready() is called after the
// browser event has already occurred.
if ( document.readyState === "complete" ) {
// Handle it asynchronously to allow scripts the opportunity to delay ready
return setTimeout( jQuery.ready, 1 );
}