Protevangelium of James 17

1Now there went out a decree from Augustus the king that all that were in Bethlehem of Judaea should be recorded. And Joseph said: I will record my sons: but this child, what shall I do with her? how shall I record her? as my wife? nay , I am ashamed. Or as my daughter? but all the children of Israel know that she is not my daughter. This day of the Lord shall do as the Lord willeth.
See also: Luke 2:1
2And he saddled the she-ass, and set her upon it, and his son led it and Joseph followed after. And they drew near (unto Bethlehem) within three miles: and Joseph turned himself about and saw her of a sad countenance and said within himself: Peradventure that which is within her paineth her. And again Joseph turned himself about and saw her laughing, and said unto her: Mary, what aileth thee that I see thy face at one time laughing and at another time sad? And Mary said unto Joseph: It is because I behold two peoples with mine eyes, the one weeping and lamenting and the other rejoicing and exulting.
3And they came to the midst of the way, and Mary said unto him: Take me down from the ass, for that which is within me presseth me, to come forth. And he took her down from the ass and said unto her: Whither shall I take thee to hide thy shame? for the place is desert.