In our textbook the given example-question is as follows (written in bold):
Find a fourier series to represent $x-x^2$ from $x= -\pi$ to $x= \pi$
But the function given $x-x^2$ is non periodic, what does it mean to have a fourier series for it, and why fourier series have a interval associated with it?
Any help is appreciated.... Thank you in advance.
You can find the Fourier series of a function $f$ defined on a closed interval $[a,b]$ where $f(a) = f(b)$. Just use the definition that you have learned in class or in your book, and take the period length $b - a$. You can view this as extending the function periodically outside of $[a,b]$, or you can view the function as defined on the interval $[a,b]$ with the end points glued together.
This works also in many cases when the function so constructed is not continuous, as in your case when $f(x) = x - x^2$ does not satisfy $f(-π) = f(π)$. Just plug the values at the end points into the integral and it will work nicely.