RationalTopAdic[x_,p_]:=Module[{fac, primes,powers,offset,ans={},re,relist={}},
fac=Transpose[FactorInteger[x*NextPrime[Max[x,p]]]];
primes=fac[[1]];
powers=fac[[2]];
If[MemberQ[primes,p],offset=powers[[Position[primes,p][[1,1]]]],offset=0];
re=x*p^(-offset);
While[(Not[MemberQ[relist,re]]&&re≠0),
relist=Append[relist,re];
ans=Append[ans,Mod[Numerator[re]*PowerMod[Denominator[re],-1,p],p,(1-p)/2]];
re=(re-Last[ans])/p];
If[re==0,
{offset,ans,{}},
{offset,Take[ans,Position[relist,re][[1,1]]-1],Drop[ans,Position[relist,re][[1,1]]-1]}]
]
pAdicToRational[padic_,p_]:=Module[{order=padic[[1]],fin=padic[[2]], inf=padic[[3]],ans,i,pp,m},
ans=p^Length[fin]*Sum[(Sum[inf[[i]]*p^(i-1),{i,1,Length[inf]}])pp^(m*Length[inf]),{m,0,Infinity}]/.{pp->p};
ans=p^order(ans+Sum[fin[[i]]*p^(i-1),{i,1,Length[fin]}])
]
smap[padic_,p_]:=Module[{ans,order=padic[[1]],fin=padic[[2]], inf=padic[[3]],digits,i},
ans=If[order≤0,
digits=Join[fin,inf];
If[Length[inf]≠0,While[Length[digits]<-order+1,
digits=Join[digits,inf]]];
p^order*Sum[digits[[i]]*p^(i-1),{i,1,Min[-order+1,Length[digits]]}]
,0];
RationalTopAdic[ans,p]
]
tmap[padic_,p_]:=pAdicToRational[padic,p]-pAdicToRational[smap[padic,p],p]
pAdicContFrac[padic_,p_]:=Module[{zeta=RationalTopAdic[padic,p],b={}},
b=Append[b,pAdicToRational[smap[zeta,p],p]];
While[zeta ≠smap[zeta,p],
zeta=RationalTopAdic[1/tmap[zeta,p],p];
b=Append[b,pAdicToRational[smap[zeta,p],p]]];
b
]

RationalTopAdic[475167/5,11]

The first entry represents the first power of p in the expansion.
The second collection represents the non-repeating part.
The third collection represents the repeating part.
This means that 475167/5 = 1*11^3 + 2*11^4 - 4*11^5 - 4*11^6 - 4*11^7 - ...

pAdicToRational[{-3,{2,1,4},{}},11]
pAdicToRational[{0,{},{2}},7]

The first shows that 2*11^(-3) + 1*11^(-2) + 4*11^(-1) = 497/1331.
The second shows that 2 + 2*7 + 2*7^2 + 2*7^3 + ... = -1/3
It's okay to leave the repeating part or nonrepeating parts empty like this.

pAdicContFrac[-1055,7]

This is our ugly example. Now it looks so pretty!

FromContinuedFraction[{2,(12/7),-(16/7),(15/7),(20/7),-(2/7)}]
Convergents[{2,(12/7),-(16/7),(15/7),(20/7),-(2/7)}]

The first function recompiles our work and shows that we were correct.
The second function lists the convergents.